Database Systems{week 05}
Rensselaer Polytechnic InstituteCSCI-4380 – Database SystemsDavid Goldschmidt, Ph.D.
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 constraints
on the information,including defining keys,referential integrity, etc.
E/R modeling goals
Fundamental goals of E/R modeling: Capture and document all requirements
and 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
Students Coursesenroll-in
<= 6
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 one chair Each faculty member can be chair of
at most one department
Faculty Departmentschair-ofC
“exactly one”“at most one”
Subclasses
Much like OOP, we candefine subclasses in anE/R diagram We identify parent/child
entity sets via the is-a relationship
The Students andFaculty relations inherit all attributes of People▪ This includes the key(s) of People
Students Faculty
People
is-a
Specialization via subclasses
Undergrads Graduates
Students
is-a
specialization
generalization
Is this a good design?
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 setskeyB keyA
Weak Entity Set
Strong Entity Set supportC
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
Weak entity sets
Strong Entity Set support
keyB keyA
Weak Entity SetC
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)
Weak entity sets – example #1
Employees depend
empid
name
DependentsC
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)
Weak entity sets – example #2
Departments offered
deptid
name
CoursesC
Weak entity sets – example #3
Advisors
Students advisesC
Majors hasC
Faculty serves-asC
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....
Exercises (reminder!)