















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















What is a Database Management System?
Relational Mo del
Based on tables, as:
acct# name balance 12345 Sally 1000. 34567 Sue 285.
To day used in most DBMS's.
Entity/Rel at io nship Mo del
Diagrams to represent designs.
Entity like ob ject, = \thing."
Entity set like class = set of \similar" entities/ob ject s.
Attribute = prop erty of entities in an entity set, similar to elds of a struct.
In diagrams, entity set! rectangle; attribute ! oval.
Students
ID name phone
height
Relationships
Connect two or more entity sets.
Represented by diamonds.
Students Taking Courses
Relationship Set
Think of the \value" of a relationship set as a table.
One column for each of the connected entity sets.
One row for each list of entities, one from each set, that are connected by the relationship.
Students Courses Sally CS Sally CS Jo e CS
Works in CS145, b ecause each TA is a TA of all students. Connection student-TA is only via the course.
But what if students were divided into sections, each headed by a TA? F Then, a student in CS145 would b e related to only one of the TA's for CS145. Which one?
Need a 3-way relationship to tell.
Students Courses
TAs
Enrolls
Students Courses TAs
Ann CS145 Don Bob CS145 Edy Cal CS145 Don
Multiplicity of Relationship s
Many-many Many-one One-one
Representatio n of Many-One
E/R: arrow p ointing to \one." F Rounded arrow = \exactly one."
Example: Drinkers Have Favorite Beers
Serves Frequents
Likes
Bars
Beers Drinkers
name addr license
name manf name addr Favorite
Attributes on Relationshi ps
Beers
price
Bars Sells
Shorthand for 3-way relationship:
Bars Sells Beers
price
Prices
A true 3-way relationship.
F Price dep ends jointly on b eer and bar.
Notice arrow convention for multiway relationships: \all other E.S. determine one of these." F Not suciently general to express any p ossibili ty. F However, if price, say, dep ended only on the b eer, then we could use two 2-way relationships: price-b eer and b eer-bar. F Or b etter: just make price an attribute of b eer.
Roles
Sometimes an E.S. participates more than once in a relationship.
Lab el edges with roles to distinguish.
Married
Drinkers
husband wife
Husband Wife d 1 d 2 d 3 d 4
Drinkers
Buddies
Buddy1 Buddy d 1 d 2 d 1 d 3 d 2 d 1 d 2 d 4
Notice Buddies is symmetric, Married not.
F No way to say \symmetric" in E/R.
Design Question
Should we replace husband and wife by one relationship spouse?
E/R Sub classes
Assume sub classes form a tree (no multiple inheritance).
isa triangles indicate the sub class relation.
isa
Beers
Ales
name manf
color
Di erent Sub class Viewp oints
isa
Beers
Ales
name manf
color
Pete's Ale