Consider the university database from previous exercise and the ER diagram you designed. Convert the ER diagram to Relational model(represent in table format)
- Table name:professors
| prof-ssn | name | age | rank | speciality |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
Primary key: prof_ssn
- Table name : Depts
| dno | Dname | office |
| | | |
| | | |
| | | |
| | | |
PRIMARY KEY: dno
- Table name Runs
| dno | prof_ssn |
| | |
| | |
| | |
| | |
PRIMARY LEY: dno +prof_ssn
FOREIGN KEY (prof ssn) REFERENCES Professors,
FOREIGN KEY (dno) REFERENCES Depts
- Table name: Work Dept
| dno | prof_ssn | pc_time |
| | | |
| | | |
| | | |
| | | |
PRIMARY KEY (dno, prof ssn),
FOREIGN KEY (prof ssn) REFERENCES Professors,
FOREIGN KEY (dno) REFERENCES Depts )
- Table name: Project
| pid | sponsor | start_date | end_date | budget |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
PRIMARY KEY (pid) )
- Table name : Graduates
| grad_ssn | age | name | deg_prog | major |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
PRIMARY KEY (grad ssn),
FOREIGN KEY (major) REFERENCES Depts
Note that the Major table is not necessary since each Graduate has only one major
and so this can be an attribute in the Graduates table.
- Table name: Advisor
| senior_ssn | grad_ssn |
| | |
| | |
| | |
| | |
PRIMARY KEY (senior ssn, grad ssn),
FOREIGN KEY (senior ssn) REFERENCES Graduates (grad ssn),
FOREIGN KEY (grad ssn) REFERENCES Graduates
- table name : Manages
| pid | prof_ssn |
| | |
| | |
| | |
| | |
PRIMARY KEY (pid, prof ssn),
FOREIGN KEY (prof ssn) REFERENCES Professors,
FOREIGN KEY (pid) REFERENCES Projects
- Table name : Work_In
| pid | prof_ssn |
| | |
| | |
| | |
| | |
PRIMARY KEY (pid, prof ssn),
FOREIGN KEY (prof ssn) REFERENCES Professors,
FOREIGN KEY (pid) REFERENCES Projects
Observe that we cannot enforce the participation constraint for Projects in the Work In table without check constraints or assertions in SQL.
- Table name : Supervises
| prof_ssn | grad_ssn | pid |
| | | |
| | | |
| | | |
| | | |
PRIMARY KEY (prof ssn, grad ssn, pid),
FOREIGN KEY (prof ssn) REFERENCES Professors,
FOREIGN KEY (grad ssn) REFERENCES Graduates,
FOREIGN KEY (pid) REFERENCES Projects
Note that we do not need an explicit table for the Work Proj relation since every time a Graduate works on a Project, he or she must have a Supervisor.