140 likes | 262 Views
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D. Database Systems {week 05}. E/R models (review). Modeling a database begins by identifying the information to be stored Need to also define how information elements are related to one another
E N D
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D. Database Systems{week 05}
E/R models (review) • Modeling a database begins by identifying the information to be stored • Need to also define how information elements are related to one another • Further, define constraintson the information,including defining keys,referential integrity, etc.
E/R modeling goals • Fundamental goals of E/R modeling: • Capture and document all requirementsand business rules as clearly and exactlyas possible • Satisfy all requirements of the given problem • Produce E/R diagrams that are easily translatable into relational models/implementations
Degree constraints • Each course has many enrolled students • Each student enrolls in many classes,but the maximum for each student is 6 <= 6 Students enroll-in Courses
Referential integrity • In a referential-integrity constraint, an entity in one set is required to have an entity in another set to which it is related • Each department has exactly onechair • Each faculty member can be chair ofat most one department “exactly one” “at most one” Faculty chair-of Departments C
Subclasses People • Much like OOP, we candefine subclasses in anE/R diagram • We identify parent/childentity sets via the is-arelationship • The Students andFaculty relations inherit all attributes of People • This includes the key(s) of People is-a Students Faculty
Specialization via subclasses generalization Students is-a Undergrads Graduates specialization Is this a good design?
Weak entity sets keyB keyA • A weak entity set is one in which itskey is not guaranteed to be unique • The weak entity set is always linked toone or more (strong) entity sets Weak Entity Set Strong Entity Set support C
Weak entity sets keyB keyA • Weak entities are determined by one or more supporting entities • The key of the supporting entities are appended to the key of the weak entity • keyA is not unique, but the combined keyA-keyB should be unique Strong Entity Set Weak Entity Set support C
Weak entity sets – example #1 empid name • Dependent names are not guaranteed unique • Names of dependents of a given employee are guaranteed to be unique • Each dependent depends on exactly one employee (required) Employees Dependents depend C
Weak entity sets – example #2 deptid name • Course names are not guaranteed to be unique • Names of courses within a given departmentare guaranteed to be unique • Each course is offered in exactly onedepartment (required) Departments Courses offered C
Weak entity sets – example #3 Students C Advisors advises has serves-as Majors C Faculty C
Exercises (reminder!) • Go back to the relations we’veworked with in class and createE/R diagrams for each • e.g. MusicGroup, Company • Also create a detailed E/R diagram for the celebrities relations (and relationships!) • see next slide....