Professional Documents
Culture Documents
Real World
Requirements Analysis
Functional
Requirements
Database
Requirements
Functional Analysis
E-R Modeling
Conceptual Design
Access
Specifications
Choice of a
DBMS
Conceptual
Model
Data Model
Mapping
Logical
Schema
Fall 2001
Logical Design
Database Systems
Physical Design
Entity-Relationship Model
An entity is a collection of real-world objects that
have many common properties.
Examples: Students, Instructors, Courses, Sections
Student entities have properties: name,
address, major, graduation-year
A student may be John Smith, 22 Sage Rd.,
Computer Science, 2000
An attribute is a data item that describes a property
of an entity
Fall 2001
Database Systems
Entities
primary identifier
sid
Students
composite attribute
student_name
lastname
Fall 2001
firstname
mid_initial
Database Systems
Fall 2001
Database Systems
Mapping Entities
Students( sid, lastname,
firstname, mid_initial )
sid
hobbies
Students
student_name
lastname
Fall 2001
firstname
mid_initial
Database Systems
#itemsold
email
Owners
owner_name
lastname
firstname
phone
buyid
Database Systems
phone
city
street
state
Fall 2001
Buyers
address
mid_initial
cc_num
zip
description
Items
name
bid
Bids
location
date/time
date
Fall 2001
Database Systems
amount
time
Relationships
Fall 2001
Database Systems
Relationships
binary relationship
own
Items
Owners
accept
Buyers
place
Bids
date
ternary relationship
Fall 2001
Database Systems
Cardinalities of Relationships
Participation cardinalities of a relationship R for an
entity E are:
min-card(E, R) : the minimum number of entities
in E that should be mapped via R
max-card(E, R): the maximum number of
entities in E that can be mapped via R
Own is a relation between owner and item
Should each owner be selling items?
How many items can an owner sell?
Fall 2001
Database Systems
10
Cardinalities of Relationships
E
One-to-one relationship
min-card(E, R)=0
max-card(E,R)=1
min-card(F,R)=0
max-card(F,R)=1
Fall 2001
Many-to-one relationship
min-card(E, R)=0
max-card(E,R)=N
min-card(F,R)=1
max-card(F,R)=1
Database Systems
Many-to-many relationship
min-card(E, R)=0
max-card(E,R)=N
min-card(F,R)=0
max-card(F,R)=N
11
Cardinalities
own
(1,1)
Items
(0,N)
Owners
(0,N)
(0,N)
accept
Buyers
Bids
place
(0,N)
(1,1)
(0,1)
date
Fall 2001
Database Systems
12
Cardinalities
Fall 2001
Database Systems
13
Fall 2001
mid_initial,
Fall 2001
Database Systems
15
Cardinalities
own
(1,1)
Items
(0,N)
Owners
(0,N)
(0,N)
accept
Buyers
Bids
place
(0,N)
(1,1)
(0,1)
date
Fall 2001
Database Systems
16
Problem
Consider the design of a database to manage airline
reservations:
For flights, it contains the departure and arrival
airports, dates and times
For flights, it also contains a number of different
pricing plans with different conditions (Saturday
stay, advance booking, etc.)
For passengers, it contains the name, telephone
number and seat type preference
Reservations include the seat assigned to a
passenger
Passengers can have multiple reservations
Fall 2001
Database Systems
17
Solution
time
date
pricing plan
depart
airport
(0,N)
(0,N)
(1,1)
(1,1)
flight
name
arrive
date
(0,N) conditions
time
(0,N)
reservation
passenger
seat
name
phone
Fall 2001
seat pref
Database Systems
18
eid
Employees
Employees(eid, , supervisor-id)
supervises
Supervisor-of
(0, N)
Recursive
relationship
employee-supervisor
(1, 1)
Employees
supervises
supervised
(0, N)
Fall 2001
project-supervisor
(1, N)
Projects
Database Systems
19
Buyers
(0,N)
amount
(0,N)
buy
Items
(0,N)
Stores
Fall 2001
BUY
Item
I1
B1
S1
I2
B1
S2
I3
B4
S1
I2
B5
S2
Database Systems
20
Buyers
(0,N)
buy_item
Items
(0,N)
(0,N)
sell_item
buy_from
(0,N)
Fall 2001
Stores
(0,N)
Is this conceptually
equivalent to the
previous ternary
relationship?
Database Systems
21
Weak Entities
Bank
(0,N)
(1,1)
has
number
name
Fall 2001
Branch
Database Systems
address
22
Weak Entities
Weak entities can be mapped to the relational
model by:
Map each weak entity E that depends on a strong
entity F to a new relation R
Relation R contains all the attributes in E and the
primary key of F
The primary key for R is the primary key of E and the
primary key of F
Fall 2001
Database Systems
23
Generalization Hierarchies
Lower items inherit attributes of their parents
date
Concerts
location
Other
orchestra
pieces
soloists
conductor
Fall 2001
performers
Database Systems
24
Extensions
All relational DBMSs come with extensions that give more
flexibility to the DBA
Examples from Informix
composite attributes -> translate as a record address of
type ROW(street string, city string, state string, zip
string)
multi-valued attributes -> translate into collection types
such as sets, lists, multi-sets (bags)
hierarchies -> create typed tables and translate into a
type hierarchy.
REMEMBER, the extensions complicate the data model
and make certain SQL queries much harder or impossible,
leaving the database programmer with a much harder job
of maintaining the database!
Fall 2001
Database Systems
25