One-to-Many Relationships to Database Schema

For Complete YouTube Video: Click Here

In this class, we will convert One-to-Many Relationships to Database Schema.

We have already discussed the concept of One-to-One Relationships to Database Schema.

One-to-Many Relationships to Database Schema

The image below is the database schema obtained so far.

Multivalued Attributes to Database Schema 3
Multivalued Attributes to Database Schema 3

The image below is the ER-Diagram.

One-to-Many Relationships to Database Schema 4
One-to-Many Relationships to Database Schema 4

In this class, we will convert all the One-to-Many Relationships to Database Schema.

In the above ER-Diagram, we have controls, dependents_of, and supervisor One-to-Many Relationships.

Controls One-to-Many Relationship

Let us start with Controls One-to-Many Relationship.

In the ER diagram design, we have obtained the relationship of the controls using the controlling department attribute.

In the database schema, we will convert the ‘controls’ relationship to Dnum, which references the Dnumber of the department table, as shown below.

One-to-Many Relationships to Database Schema 1
One-to-Many Relationships to Database Schema 1

Dependents_of One-to-Many Relationship

Similarly, if we consider the dependents_of relationship type, it was obtained by employee attribute.

In the dependents table, the combination of Name and Essn is considered the primary key, and essn is referencing the ssn of the employee table, as shown below.

One-to-Many Relationships to Database Schema 2
One-to-Many Relationships Database Schema 2

Supervisor One-to-Many Relationship

We got the supervisor relationship by the supervisor attribute of the employee table.

In the database schema, we will add a new column by the name super_ssn that references the ssn of the employee table, as shown below.

One-to-Many Relationships to Database Schema 3
One-to-Many Relationships Database Schema 3