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.
Table of Contents
One-to-Many Relationships to Database Schema
The image below is the database schema obtained so far.
The image below is the ER-Diagram.
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.
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.
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.