Page 129 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 129

Database Management Systems/Managing Database




                    Notes
                                                              Figure  7.7: Class  Hierarchy

                                                                              name
                                                                   ssn                    lot



                                                                            Employees




                                                                              ISA
                                                                                             name
                                                           hours_worked
                                                hourly_wages


                                                               Hourly_Emps             Contract_Emps

                                   1.  We can map each of the entity sets Employees, Hourly_Emps, and Contract_Emps to a
                                       distinct  relation.  The  relation  for  Hourly_Emps  includes  the  hourly_wages  and
                                       hours_worked  attributes  of  Hourly_Emps. It  also  contains  the  key  attributes of  the
                                       superclass, which serve as the primary key for Hourly_Emps, as well as a foreign key
                                       referencing the superclass (Employees). For each Hourly_Emps entity, the value of the
                                       name and lot attributes are stored in the corresponding row of the superclass (Employees).
                                   2.  We can create just two relations, corresponding to Hourly_Emps and Contract_Emps. The
                                       relation for Hourly_Emps includes all the attributes of Hourly_Emps as well as all the
                                       attributes of Employees (i.e., ssn, name, lot, hourly_wages, hours_worked).
                                   The first approach is general and is always applicable. Queries in which we want to examine all
                                   employees and  do not care about the attributes specific to the subclasses  are handled  easily
                                   using the Employees relation.
                                   The second approach is not applicable if we have employees who are neither hourly employees
                                   nor contract employees, since there is no ways to store such employees. Also, if an employee is
                                   both an Hourly_Emps and a Contract_Emps entity, then the name and lot values are stored twice.
                                   This duplication can lead to some of the anomalies.
                                   Translating ER Diagrams with Aggregation: Translating aggregation into the relational model
                                   is easy because there is not real distinction between entities and relationships in the relational
                                   model.
                                   Consider the ER diagram shown in Figure 7.8. The Employees, Project, and Departments entity
                                   sets and the Sponsors relationship set are mapped as described in previous sections. For the
                                   Monitors relationship set, we create a relation with the following attributes: the key attributes
                                   of Employees (ssn), the key attributes of Sponsors (did,  pid), and the descriptive attributes of
                                   Monitors (until).















          122                               LOVELY PROFESSIONAL UNIVERSITY
   124   125   126   127   128   129   130   131   132   133   134