GATE / CS ARCHIVE

SIMILAR QUESTIONS / DATABASE MANAGEMENT SYSTEMS

Count tables needed for ER relationship cardinalities

3 questions solved the same way, newest first. Back to Database Management Systems

How these are solved

Map entities and weak entities, absorb suitable many-to-one relationships as foreign keys, and retain separate many-to-many relations. Cardinality and participation determine whether merging is valid.

2 marks · NAT
Report issue

Database Models, Architecture & ER Diagrams

Question 48, GATE 2015: Entities E1,E2,E3 have single-valued attributes (a11 key,a12),(a21 key,a22),(a31 key,a32). E1–E2 has m:n relationship R12; E1–E3 has 1:n R13, n on E3 side. Relationships have no attributes. Find minimum relations when all are in 3NF.
Tap to enlarge
Answer & solution

Official answer: 4

Construct E1(a11,a12), E2(a21,a22), E3(a31,a32,a11), and R12(a11,a21). E3's added a11 foreign key records its single associated E1 without a separate R13 table. R12 needs a separate association relation because either entity may participate in multiple pairs. Given only the stated dependencies, these four relations meet 3NF; merging an entity's nonkey attributes into R12 would introduce redundant dependencies.

Solution: Use one relation for each of the three entity types. Implement the 1: n relationship by a foreign key on the n side, requiring no extra relation. The m: n relationship needs its own relation containing the participating keys. Thus four relations suffice under the displayed constraints.

Original paper, page 18 · Answer key

2 marks · MCQ
Report issue

Minimum relations for an ER diagram

Database Models, Architecture & ER Diagrams

Question 82, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. What is the minimum number of tables in the standard relational mapping?

(A) 2
(B) 3
(C) 4
(D) 5
Question 82, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. What is the minimum number of tables in the standard relational mapping?

(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Use three relations: P(P1,P2), M(M1,M2,M3,P1), and N(P1,N1,N2). R1 is many-to-one from M to P with total participation of M, so a P1 foreign key in M represents it without a separate relationship table.
2. N is weak, R2 is its identifying many-to-one relationship with P, and N1 is the partial key; include P1 in N, whose primary key is (P1,N1). Thus the standard ER-to-relational mapping needs three tables, option B.

Original paper, page 18

2 marks · MCQ
Report issue

Tables for two entity relationships

Database Models, Architecture & ER Diagrams

Question 75, GATE 2005: Two ER entities E1, E2 have simple single-valued attributes and two relationships between them: R1 one-to-many and R2 many-to-many, neither with attributes. Minimum relational tables: A2; B3; C4; D5.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Use one table for each entity set. The one-to-many relationship is represented by placing the one-side key as a foreign key in the many-side table, so it needs no separate table. The many-to-many relationship needs a third junction table containing the two entity keys. Minimum: three tables, option B.

Represent each entity type by a table, giving two. The many side of R1 can store the one-side primary key, since each many-side instance relates to at most one one-side instance; no junction table is necessary. R2 needs a junction table because either side can have several partners. Its pair of foreign keys records each pair, bringing the minimum to three.

Original paper, page 10