Professional Documents
Culture Documents
E-R Model
Basic ER modelling
Extensions to ER modelling
Designing an ER schema
CS446/646
E-R Model
Overview of ER Model
Proposed by Peter Chen in 1976
entities
attributes
relationships
Visualization: ER-diagram
CS446/646
E-R Model
Basic ER Modelling
Entity: a distinguishable object
CS446/646
E-R Model
Student
Major
StudentNum
StudentName
CS446/646
E-R Model
CS446/646
E-R Model
RegisteredIn
Course
CourseNum
CS446/646
E-R Model
BranchName
AccountNum
Branch
Account
Balance CAB
StreetAddr
Customer
SIN
CustomerName
CustomerCity
CS446/646
E-R Model
Address
TeamName
LocName
Role labels are needed whenever an entity set has multiple functions in a relationship set.
CS446/646
E-R Model
Score
Address
TeamName
LocName
CS446/646
E-R Model
Contraints in ER Models
Binary relationship types
Primary keys
Existence dependencies
10
CS446/646
E-R Model
many-to-one (N:1): each entity in A can be related to at most one entity in B, but an entity in B may be related to many entities in A
Visualization:
Ex.
Employee
WorksIn
Department
11
CS446/646
E-R Model
Ex.
Employee
Manages
Department
many-to-many (N:N): an entity can be related to many entities in the other set, and vice versa
Ex.
Employee
WorksOn
Project
12
CS446/646
E-R Model
Visualization:
(lower,upper)
. . .
Ex.
Student
(3,5)
Takes
(6,100)
Course
13
CS446/646
E-R Model
Primary Keys
As in relational model, each entity must be distinguishable from any other entity in its set by its attributes
Primary key: selection of attributes chosen by designer as a surrogate key of the entity set Ex.
Dnum
Department
ManagerName
Dname
Budget
Ex.
FirstName
Employee
Salary
Initial
LastName
14
CS446/646
E-R Model
Existence Dependencies
Sometimes the existence of an entity depends on the existence of another entity
If
is a dominant entity
is a subordinate entity
Balance
AccNum
TransNum
Date
Amount
15
CS446/646
E-R Model
Ex. All transactions for a given account have a unique transaction number.
Balance
AccNum
TransNum
Date
Amount
16
CS446/646
E-R Model
Discriminator of a weak entity set: set of attributes that distinguish subordinate entities of the set, for a particular dominant entity
Primary key for a weak entity set: discriminator entity set for dominating entities
primary key of
Identifying Relationship
Other Relationship
17
CS446/646
E-R Model
Example ER Diagram
CourseNum
CourseName
Section
StudentName
18
CS446/646
E-R Model
Extensions to ER Modelling
Structured attributes
Aggregation
Specialization
Generalization
19
CS446/646
E-R Model
Structured Attributes
Composite attributes: attributes composed of two or more other attributes
Ex.
Street
Employee
Address
City
20
CS446/646
E-R Model
Aggregation
Relationships can be viewed as higher-level entities
CourseNum
Student
EnrolledIn
Course
21
CS446/646
E-R Model
Specialization
A more specialized kind of entity set may be derived from a given entity set
Ex. Graduate students are students that have a supervisor and a number of degrees.
StudentNumber Student StudentName
Graduate
N (1, 1)
SupervisedBy
1 (0, N)
Professor
Degrees
ProfessorName
22
CS446/646
E-R Model
Generalization
Two or more existing entity sets can be abstracted as a more general kind of entity set Ex. A vehicle abstracts the notion of a car and a truck.
PassengerCount
LicenceNum
Car
MaxSpeed
Price
MakeAndModel
AxelCount
LicenceNum
Truck
Tonnage
Price
MakeAndModel
23
CS446/646
E-R Model
Generalization (contd)
MakeAndModel
LicenceNum
Vehicle
Price
Tonnage
Truck
Car
MaxSpeed
AxelCount
PassengerCount
24
CS446/646
E-R Model
Expressing Disjointness
Tonnage
Truck
Car
MaxSpeed
AxelCount
PassengerCount
25
CS446/646
E-R Model
Designing An ER Schema
Usually many ways to design an ER schema
Points to consider
degrees of relationships?
extended features?
26
CS446/646
E-R Model
Ex. Should one model employees phones by a PhoneNumber attribute, or by a Phone entity set related to the Employee entity set?
Is it a separate object?
An afrmative answer to any of the above implies introducing a new entity set.
27
CS446/646
E-R Model
BranchName
Branch Balance
Account AccountNum
StreetAddr
Customer
SIN
CustomerName
CustomerCity
28
CS446/646
E-R Model
binary
BranchName
AccountNum
Branch
Account
CABCustomer
StreetAddr
Customer
SIN
CustomerName
CustomerCity
29
CS446/646
E-R Model
30
CS446/646
E-R Model
A Simple Methodology
1. Recognize entity sets 2. Recognize relationship sets and participating entity sets 3. Recognize attributes of entity sets and attributes of relationship sets 4. Dene binary relationship types and existence dependencies 5. Dene general cardinality constraints, keys and discriminators 6. Draw diagram
For each step, maintain a log of assumptions motivating the choices, and of restrictions imposed by the choices
31