Conclussion:
|
|
The first method is always possible
|
The second method is preferred:
|
but.... as we will see soon: method 2 does not work all the time
|
(EmployeeSSN, DNumber) (They are primary keys of each entity) |
|
|
Notice that:
|
Again, the relation Employee already has the SSN attribute....
So we just have to add the DNumber attribute from the department to Employee....
Result:
This expansion will work, because DNo is single-valued !!!
SSN FName MI LName ... DNo --------------------------------------------------- 123-45-6789 John X Smith 4 111-11-1111 Kate Y Smith 1 222-22-2222 Peter Z Pan 1 |
We can see from the tuples stored that:
|
To represent a relationship
Entity1:Entity2 = 1:Nexpand the relation that represents Entity2 |
by adding (DNum) to the Project relation
by adding (SupervisorSSN) to the Employee relation - this SSN plays the role of the supervisor
(NOTE: if you add (SuperviseeSSN) - an SSN number that plays the role of the supervisee, then this attribute is multivalued....)
Since the relationship is Employee:Department = 1:1, "ManagedDNum" will have atomic attribute values.
Again, the relationship is Employee:Department = 1:1, so "MgrSSN" will also have atomic attribute values.
Yes, definitely. Look at the participation constraints:
Employee(SSN, FName, MI, LName, ...., ManagedDNum)
The attribute ManagedDNum will contain NULL values because the participation of Employee is partial, i.e., no every employee will have a department to manage.... - employees that do not manage departments will have ManagedDNum = NULL
Department(DName, DNumber, ...., ManagerSSN)
The attribute ManagerSSN will NEVER contain NULL values because the participation of Department is TOTAL, i.e., every department will have a manager !!!
|
NULL values can be a headach in formulation of some queries.
|
|
Department(DName, DNumber, ...., ManagerSSN, StartDate ) |
Sample tuples to show you that we successfully represented the Manage relationship:
DName DNumber .... ManagerSSN StartDate ------------------------------------------------------------------------- Payroll 4 123-45-6789 1/1/2000 Adm. 1 111-11-1111 3/1/2010 |
Can you tell which employee is the manager of the Payroll department ?
|
Can you tell when this employee started managing the Payroll department ?
|
Since the relationship is Employee:Project = M:N, "WorkedOnProjects" will be multi-valued.
Again, the relationship is Employee:Project = M:N, so "WorkerSSN" will also be multi-valued....
When you put everything together (as I have shown in class), you will get the following relational model:
|
|