database systems {week 05}

14
Database Systems {week 05} Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.

Upload: dugan

Post on 23-Feb-2016

35 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Database Systems {week  05}

Database Systems{week 05}

Rensselaer Polytechnic InstituteCSCI-4380 – Database SystemsDavid Goldschmidt, Ph.D.

Page 2: 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 constraints

on the information,including defining keys,referential integrity, etc.

Page 3: Database Systems {week  05}

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

Page 4: Database Systems {week  05}

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

Page 5: Database Systems {week  05}

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”

Page 6: Database Systems {week  05}

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

Page 7: Database Systems {week  05}

Specialization via subclasses

Undergrads Graduates

Students

is-a

specialization

generalization

Is this a good design?

Page 8: Database Systems {week  05}

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

Page 9: Database Systems {week  05}

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

Page 10: Database Systems {week  05}

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

Page 11: Database Systems {week  05}

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

Page 12: Database Systems {week  05}

Weak entity sets – example #3

Advisors

Students advisesC

Majors hasC

Faculty serves-asC

Page 13: Database Systems {week  05}

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....

Page 14: Database Systems {week  05}

Exercises (reminder!)