Download presentation
Presentation is loading. Please wait.
Published byHenry Crawford Modified over 8 years ago
1
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
2
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.
3
An entity is a building block of our database, abstracting an object of some sort e.g. movie, faculty member, student An entity set is a collection of similar entities e.g. all movies, all faculty members, all students This is similar to the object/class concepts of OOP, but there are no methods/functions
4
Each entity set has a key and (usually) other attributes The key consists of one or more attributes The key should functionally determine all other attributes! Entity sets should be in BCNF or 3NF Entity sets should not have attributes that relate to other entity sets, unless they are foreign keys
5
An E/R diagram is a graph representing: Entity sets (rectangles) Attributes (ovals) Relationships (diamonds) ▪ i.e. connections between two or more entity sets Students Courses id name enroll-in E/R diagrams are a notation for describing database schemas keys are underlined
6
Each course has many enrolled students Each students enrolls in many classes Note that many implies zero or more Students Courses enroll-in
7
Each department has many faculty Each faculty member belongs to at most one department (so zero or one) Faculty Departments in “at most one”
8
Each department has at most one chair Each faculty member can be chair of at most one department Faculty Departments chair-of
9
For a particular major and student, there is at most one faculty member who is the advisor A faculty member may advise many students in many majors Students Faculty advised-by Majors
10
A student enrolls in a course with at most one department code (e.g. CSCI) Is this the correct relationship? Students Courses enroll-in DeptCodes (e.g. CSCI)
11
The department code is actually functionally determined by the course itself (e.g. by CRN) Note that this does not account for cross-listed courses.... Students Courses enroll-in DeptCodes (e.g. CSCI) has
12
Is this the correct relationship? It is correct (and necessary) if a faculty member can advise students across multiple majors Otherwise, each faculty should functionally determine the major s/he advises Students Faculty advised-by Majors
13
A movie may have many sequels For each sequel, there is at most one original movie Movies sequel-of original sequel exactly one in this case... role
14
The grade attribute is associated with the given relationship ▪ And involves both a student and a course This is merely a shortcut.... Students Courses enroll-in grade
15
The grade attribute of the Grades entity set (relation) is functionally determined by the entire tuple involving Students and Courses i.e. a student enrolled in a course has a grade Students Courses enroll-in Grades grade
16
Go back to the relations we’ve worked with in class and create E/R diagrams for each e.g. MusicGroup, Company Also create a detailed E/R diagram for the celebrities relations (and relationships!) see next slide....
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.