Professional Documents
Culture Documents
Entity/Relationship modelling
www.cl.cam.ac.uk/Teaching/current/Databases/ 1
Database design lifecycle
• Requirements analysis
– User needs; what must database do?
• Conceptual design
– High-level description; often using E/R model Today
• Logical design
– Translate E/R model into (typically) relational schema
• Schema refinement
– Check schema for redundancies and anomalies
• Physical design/tuning
– Consider typical workloads, and further optimise
2
Today’s lecture
• E/R modelling
– Entities
– Attributes
– Relationships
– Constraints on relationships
• Extended E/R modelling
– Object ideas
3
Conceptual Design
Employees
Employees
6
Key attributes
Employees 7
Relationships
8
Relationships in E/R
9
Relationship set diagrams
e2 r2 d2
e3 r3 d3
e4 d4
r4
e5 d5
… … …
10
Relationship attributes
Name dname
NI dob since DID budget
11
N-ary relationships
12
Recursive relationships
13
Recursive relationships in E/R
e.g. name
dob
NI
Employees
supervisor subordinate
Reports-to
14
Constraints on relationship
types
• For example:
– An employee can work in many departments; a
department can have many employees
– In contrast, each department has at most one
manager
• Thus we need to be able to specify the
number of relationship instances that an
entity can participate in.
• For binary relationships the possible ratios
are: 1:1, 1:N, N:1, M:N
15
Cardinality ratios
1:1 1:N
M:N
16
Cardinality ratios in E/R
M N
M:N
N 1
N:1
1 1
1:1
17
Participation constraints
dname
Name DID budget
NI dob since
1 N
Employees Manages Department
19
Weak entity types
20
Weak entity types cont.
1 N
Employees Policy Dependents
21
Extended E/R modelling
Temp_Emp Contract_Emp
23
Attribute inheritance
24
Aggregation
N M
Projects Sponsors Departments
25
Aggregation cont.
26
Aggregation cont.
NI name
Employees
Monitors until
since
start dname
PID budget DID budget
N M
Projects Sponsors Departments
27
A Data Model from the
European Bioinformatics Institute (EBI)
See http://intact.sourceforge.net/uml/intactCore.gif
28
Summary