You are on page 1of 34

Fundamentals of Database systems

DSE 310
Practice-3
Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1
and R2 are two relationships between E1 and E2, where R1 is one-to-many and R2 is
many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum
number of tables required to represent this situation in the relational model?
Strong entities E1 and E2 are represented as separate tables.

In addition to that many-to-many relationships(R2) must be converted as separate


table by having primary keys of E1 and E2 as foreign keys.

One-to-many relaionship (R1) must be transferred to ‘many’ side table(i.e. E2) by


having primary key of one side(E1) as foreign key( this way we need not to make
a separate table for R1).
R1(A,B,C) and R2(D, E)

Foreign Key

There are no tuples which belong to C and don’t belong to


D
A(a1,a2 )
BR1(b1,b2,a1)
CR2(c1,c2,a1)
R3(b1,c1)
Which one of the options given below refers to the
degree (or arity) of relation in relational database
systems? [GATE CSE 2023]
(A) Number of attributes of its relation schema.
(B) Number of tuples stored in the relation.
(C) Number of entries in the relation.
(D) Number of distinct domains of its relation schema.
Q. Referential Integrity constraints functions use the
________ concept
(a) Primary key
(b) Super key
(c) Foreign key
(d) Secondary key
Q. In the E-R diagram, the entity set person has UID, age, sex and
address attributes with UID as the primary key. The address is
multi-valued composite attribute comprised of street number, city
and pin code. When this entity set is mapped to relational model,
the relations are:
a) Person(UID, age, sex, address)
b) Person (UID, age, sex) and Person_address(UID, street number,
city ,pin code)
c) Person(UID, age, sex, street number, city, pincode)
d) None of the above
Solution: Foreign Key: Manager_id
It takes all values form Employee_id, it
Foreign key
doesnot have its own existence.
It is the subset of Employee_id.

So, if certain tuple from Employee_id is


deleted, it has to be deleted from
Manager_id in order to maintain refrential
integrity.

If (20,40) is deleted, then tuple with


Manager_id 20 will be deleted,
i.e.,(35,20).

Now again (35,20) is deleted, then tuple


with Manager_id 35 is deleted, i.e.,
(30,35)……and so on.
Q. The following table has two attributes A and C where A is the primary key and
C is the foreign key referencing A with on-delete cascade. Find the set of all
tuples which must be additionally deleted to maintain the referential integrity of
table when the tuple (2,4) is deleted:
A C (a) (3,4) and (6,4)
2 4

3 4 (b) (5,2) and (7,2)


4 3

5 2
(c) (5,2), (7,2) and (9,5)
7 2

9 5
(d) (3,4), (4,3) and (6,4)
6 4
A C (FK)

2 4

3 4

4 3

5 2

7 2

9 5

6 4
Q. Construct appropriate tables for following E-R diagrams?
Car insurance tables:
person (driver-id, name, address)
car (license, year, model)
accident (report-number, date, location)
participated(driver-id, license, report-number,
damage-amount)
owns(driver-id, license)
Thetha Join/Conditional Join
S1.sid name rating age R1.sid bid day
22 dustin 7 45.0 58 103 11/12/96
31 lubber 8 55.0 58 103 11/12/96
S1.id<R1.sid
S1.sid name rating age R1.sid bid day

22 dustin 7 45.0 22 101 10/10/96

22 dustin 7 45.0 58 103 11/12/96

31 lubber 8 55.0 22 101 10/10/96

31 lubber 8 55.0 58 103 11/12/96

58 rusty 10 35.0 22 101 10/10/96

58 rusty 10 35.0 58 103 11/12/96


Natural Join

sid Name rating age bid day


22 dustin 7 45.0 101 10/10/96
58 rusty 10 35.0 103 11/12/96
Equi-Join

You might also like