DBMS Practice Questions Gate 2025
DBMS Practice Questions Gate 2025
1. ER Models
1) Draw an ER diagram to represent: “a person has only one passport and a passport is given
to one person”
Solution:
2) Draw an ER diagram to represent: “a customer can place many orders but a order cannot
be placed by many customers”
Solution:
3) Draw an ER diagram to represent: “many students can study in a single college but a
student cannot study in many colleges at the same time”
Solution:
Solution:
5) Construct an E-R diagram for a car insurance company whose customers own one or more
are each. Each car has associated with it zero to any number of recorded accidents. Each
insurance policy covers one or more ars and has one or more premium payments associated
with it. Each payment is for a particular period of time, and has an associated due date, and
the date when the payment was received.
Solution:
6) Design an E-R diagram for keeping track of the scoring statistics of your favorite sports
team. You should store the matches played, the scores in each match, the players in each
match, and individual player scoring statistics for each match.
Solution:
7) Construct an E-R diagram for a hospital with a set of patients and a set of medical doctors.
Associate with each patient a log of the various tests and examinations conducted.
Solution:
8) A weak entity set can always be made into a strong entity set by adding to its attributes the
primary-key. In this context, choose the statement(s) that are correct [MSQ]
9) We can convert any weak entity set to a strong entity set by simply adding appropriate
attributes. Then, the purpose(s) of having weak entity is/are [MSQ]
Solution: (A)(B)(C)(D)
We have weak entities for several reasons:
• We want to avoid the data duplication and consequent possible inconsistencies caused by
duplicating the key of the strong entity.
• Weak entities reflect the logical structure of an entity being dependent on another entity.
• Weak entities can be deleted automatically when their strong entity is deleted.
10) In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity
set E1 to entity set E2. Assume that E1 and E2 participate totally in R and that the cardinality
of E1 is greater than the cardinality of E2. Which one of the following is true about R?
Solution: (A)
E1 to E2 is a many to one relationship. Hence,
No entity in E1 can be related to more than one entity in E2, and an entity in E2 can be
related to more than one entity in E1.
11) Given the basic ER and relational models, which of the following is INCORRECT?
Answer: (C)
The term ‘entity’ belongs to the ER model and the term ‘relational table’ belongs to the
relational model. ER model supports both multivalued and composite attributes.
In Relation model, an entry in a relational table can have exactly one value or a NULL.
2. Relational Database Model
Solution: (A)(B)(D)
Structural Independence: The relational database is only concerned with data and not with a
structure. This can improve the performance of the model.
Data independence: The Structure of Relational database can be changed without having to
change any application.
Relational databases have limits on field lengths which can't be exceeded.
Relational databases provide methods to validate domain constraints.
A) The value in referencing relation cannot be inserted, if the referencing attribute’s value is
not present in referenced attribute value.
B) A row cannot be deleted or updated from referenced relation, if the value of referenced
attribute is used in value of referencing attribute.
C) A primary key cannot be a composite key.
D) A proper subset of super keys is called a candidate key.
A) Domain constraints
B) Key constraints
C) Entity Integrity constraints
D) None of the constraints are violated.
Solution: (A)
Domain constraints: Every domain must contain atomic values. Hence, composite and
multi-valued attributes are not allowed.
A) Domain constraints
B) Key constraints
C) Entity Integrity constraints
D) None of the constraints are violated.
Solution: (B)
Key constraints: EMP_ID is the primary key, and third and the last tuple has the same value in
1238, so it is violating the key constraint.
A) Domain constraints
B) Key constraints
C) Entity Integrity constraints
D) None of the constraints are violated.
Solution: (C)
Entity Integrity constraints: no primary key can take NULL value, since using primary key we
identify each tuple uniquely in a relation. EMP_ID is the primary key, and last tuple has the
Null value, so it is violating the entity Integrity constraint.
A) In referential integrity it is required that the primary key and the foreign key have the same
data types.
B) Referential integrity requires that a foreign key must have a matching primary key.
C) Referential integrity can be achieved even if the foreign key value is set to null.
D) In referential integrity it is required that the primary key and the foreign key have the same
domain.
Solution: (D)
Al are super keys since each set can uniquely identify each student in the Student table.
9) Let R(A1,A2,A3) be a relational schema with A1 as the candidate key. Then the number of
super keys possible are ________ [NAT]
Solution: 4
Any superset of candidate key A1 is the super key.
Hence, super keys are A1, A1A2, A1A3, A1A2A3.
Example 1: https://elearning.ravindrababuravula.com/materials/course/15/2459
Example 2: https://elearning.ravindrababuravula.com/materials/course/15/2460
Example 3: https://elearning.ravindrababuravula.com/materials/course/15/2461
Example 4: https://elearning.ravindrababuravula.com/materials/course/15/2462
3. Conversion of ER model to Relational model
Solution:
A strong entity set with only simple attributes will require only one table in a relational model.
1 Ajay 32
2 Anil 32
3 Vishwa 31
Solution:
● A strong entity set with any number of composite attributes will require only one table
in a relational model.
● While conversion, simple attributes of the composite attributes are taken into account
and not the composite attribute itself.
Solution:
A strong entity set with any number of multi valued attributes will require two tables in
relational model.
● One table will contain all the simple attributes with the primary key.
● Other table will contain the primary key and all the multi valued attributes.
Solution:
A relationship set will require one table in the relational model. Attributes of the table are-
Relational schema: Employees (ssn, name, lot) Departments (did, dname, budget)
Works_In ( ssn, did, since)
Solution:
Relational schema: A ( a1 , a2 ), R ( a1 , b1 ), B ( b1 , b2 )
Q6) Convert the following ER-model to relational schema.
Solution:
Relational schema: A ( a1 , a2 ) BR ( a1 , b1 , b2 )
Solution:
Relational schema: AR ( a1 , a2 , b1 ) B ( b1 , b2 )
Solution:
Relational schema: AR ( a1 , a2 , b1 ) B ( b1 , b2 ) OR A ( a1 , a2 ) BR ( a1 , b1 , b2 )
Solution:
Because cardinality ratio = 1 : n , so we will combine the entity set B and relationship set R.
Relational schema: A ( a1 , a2 ) and BR ( a1 , b1 , b2 )
Because of total participation, foreign key a1 is NOT NULL.
Solution:
If there is a key constraint from both the sides of an entity set with total participation, then that
binary relationship is represented using only one table.
Relational schema: ARB ( a1 , a2 , b1 , b2 )
Solution:
Weak entity set always appears in association with identifying relationship with total
participation constraint
Relational schema: A ( a1 , a2 ) BR ( a1 , b1 , b2 )
Q12) Find the minimum number of tables required for the following ER diagram in relational
model
Solution:
Relational schema: Minimum 3 tables will be required:
MR1 (M1 , M2 , M3 , P1) P (P1 , P2) NR2 (P1 , N1 , N2)
Q13) Find the minimum number of tables required to represent the given ER diagram in
relational model
Solution:
Relational schema: minimum 4 tables will be required-
AR1R2 (a1 , a2 , b1 , c1) B (b1 , b2) C (c1 , c2) R3 (b1 , c1)
Q14) Find the minimum number of tables required to represent the given ER diagram in
relational model
Solution:
Relational schema: minimum 5 tables will be required:
BR1R4R5 (b1 , b2 , a1 , c1 , d1) A (a1 , a2) R2 (a1 , c1) CR3 (c1 , c2 , d1) D (d1 , d2)
Q15) Find the minimum number of tables required to represent the given ER diagram in
relational model
Solution:
Relational schema: minimum 3 tables will be required:
E1 (a1 , a2) E2R1R2 (b1 , b2 , a1 , c1 , b3) E3 (c1 , c2)
Solution:
• Entity-set schemas: job (title, level ) employee (employee_id, employee_name ) branch
(branch_name, branch_city, assets )
• Relationship-set schema: – Primary key includes entity-sets on non-arrow links works_on
(employee_id, branch_name, title )
Solution:
Solution: