Professional Documents
Culture Documents
CDMLDM
CDMLDM
Relationships
A relationship is an association among two or more entities. For example, a
STUDENTS entity might be related to a COURSES entity, or an EMPLOYEE entity
might be related to an OFFICES entity.
When these relationships are implemented in the database, they provide the links
among the various tables.
Inheritance
■Supertypeentity: an entity that is in relation with one or more subtype
entities. It contains attributes that are common with it sub entities.
■Subtype entity: it is a part of a supertypeentity. It has unique
attributes.
1
B) Relationship 1, 1 – 0, 1
■ The identifier of the entity with cardinality 0,1 is added as a foreign key to the
table resulting from the entity with 1, 1 cardinality
Employee ( EmpID, Name)
Department (DepID, NameDep, EmpID)
C) Relationships 1, n – 1, n 1, n – 0, n 0, n – 0, n
The relation becomes a new table
The new table has the identifiers of the 2 entities as a primary key
The properties of the relation become columns of the new table
Driver (DriverID, Name)
Competition (CompetitionID, date)
Position (DriverID, Rank, CompetitionID)
D) Relationships 0, 1 – 0, n or 0, 1 – 1, n
The relation becomes a new table. It has:
The identifier of the entity with 0,1 cardinalities as a primary key
The primary key of the entity with 0, n cardinality as a foreign key
Attributes of the relation as columns:
Employee (EmpID, Name)
Project (ProjectID, Budget)
Works On (EmpID, dateStart, ProjectID)
E) Relationships 0, 1 - 0, 1
The relation becomes a new table. It has:
The identifier of the independent entity as a primary key
The identifier of the dependent entity as a foreign key
The attributes of the relation as columns
Closet (ClosetID)
Student (StudentID, Fname, Lname)
Own (StudentID, OwnDate, ClosetID)
F) Relationships 1, 1 - 1, 1
-The identifier of the independent entity is a foreign key in the dependent entity
Invoice (InvoiceID, InvDate)
Receipt (ReceiptID, RecDate, RecAmount, InvoiceID).