Documente Academic
Documente Profesional
Documente Cultură
●
Relations are stored in tables
Relational Databases – e.g. Sponsor(Senator,Bill)
Sponsor Atrributes
CPSC 315 – Programming
Senator Bill
Studio
Smith Tax
Fall 2010
Jones Defense
Project 1, Lecture 2 Smith Defense
Tuples
Name
Years
Bill
Name Text
ER Relationships Relations
●
Sponsored(Senator,Bill)
Name
●
Wrote(Bill,Lobbyist)
Contributed
●
Contributed(Senator,Lobbyist)
Party Organization
Senator
State Lobbyist
●
Remember, each of these is expressed as a
table (with the columns given by the
Years Sponsored
Name “parameters”)
Wrote ●
Notice that columns can refer to “bigger”
Bill
items, with even more attributes
Name Text
Combining Relations Combining Relations
●
Relations can sometimes be combined. ●
Example (many-to-one): (Good)
– Person(Name, Birthdate, Height, Weight, Eye
●
Assume a “base” entity set with its Color, Hair Color)
relation. – BornIn(Person,Town)
●
If there is a many-to-one relation, that – Person(Name, Birthdate, Height, Weight, Eye
can be combined with the base entity Color, Hair Color, Town)
set. ●
Example(many-to-many): (Bad)
– Senator(Name, Party, State, Years)
●
Should not combine many-to-many – Sponsored(Senator, Bill)
– Redundancy – each of the many stored – Senator(Name, Party, State, Years, Bill)
Birthdate
Plays
Team
Nationality Salary On
City Name
Weak Entity Set Example Weak Entity Set Example
●
Team(Name, City) ●
Team(Name, City)
●
Baseball Player(Number, TeamName,
●
Baseball Player(Number, TeamName,
First Name, Last Name, Position, First Name, Last Name, Position,
Birthdate, Nationality, Salary) Birthdate, Nationality, Salary)
●
Note that we don’t need
PlaysOn(BaseballPlayer.Number,
BaseballPlayer.TeamName,
Team.Name)
Party
Birthdate, Nationality, Salary)
●
Note that we don’t need isa
PlaysOn(BaseballPlayer.Number, U.S.
District
BaseballPlayer.Team.Name) Representative
Already
Included
●
Can save space, but problematic if multiple
subclasses or lots of NULLs