MERISE Design
MERISE Design
Entity / Relationship
Yann Thierry-Mieg
EFREI 2006-2007
Goal :
Graphical description of a database schema
Independent from actual database realization (network,
RDBMS)
Advantages :
Automatic translation to a physical relational data model
Good tool support (i.e. Sybase AMC suite)
Description levels
Y. Thierry-Mieg - 19 Septembre 2005
Order
<pi> A6 <O>
Order_id
order_date
D <O>
Order line
1,n
Qty I
0,n
PK_Order <pi>
<O>
Item_id <pi> A9
desc
VA30
price
MN
PK_item <pi>
Order(Order_id,Order_date)
Item(Item_id,Desc,price)
Order_line (Order_id*,Item_id*,Qty)
Physical level
Primary and foreign keys
Indexes, tablespace
SQL commands
Conceptual level
Item
Order
<pi> A6 <O>
Order_id
order_date
D <O>
Order line
1,n
Qty I
0,n
PK_Order <pi>
<O>
Item_id <pi> A9
desc
VA30
price
MN
PK_item <pi>
Physical Level
Order line
Order_id CHAR(6) <pk,fk1>
Item_id CHAR(9) <pk,fk2>
Qty
INTEGER
FK_ORDER_LI_ORDER_LIN_ORDER
FK_ORDER_LI_ORDER_LIN_ITEM
Order
Item
CHAR(6) <pk>
Order_id
order_date DATE
<pk>
Item_id CHAR(9)
desc
VARCHAR2(30)
price
NUMBER(8,2)
Entity : Definition
Y. Thierry-Mieg - 19 Septembre 2005
An
0012 14-MAR-98
Entity type
Y. Thierry-Mieg - 19 Septembre 2005
Attribute_n
Person
SS number
Name
Last name
Birth date
Order
(in PowerAMC)
Order_id
<pi> A6 <O>
order_date
D <O>
PK_Order <pi>
Entity Identifier
Y. Thierry-Mieg - 19 Septembre 2005
Graphically:
Underlined in the entity definition
Examples
Soc. Sec. number of a person
Order id of an order
Association or Relation
Y. Thierry-Mieg - 19 Septembre 2005
significant for the business model, and links together two or more
entities. A relation may additionally bear a set of attributes.
Links entities in an E/R schema
Not standalone : defined with respect to existing entities
Graphically :
Order line
Association name
Qty I
Att_1
Att_n
Company
Employee
Person
Dimension of a Relation
Y. Thierry-Mieg - 19 Septembre 2005
Person
Marriage
SS_num
date
Role
Y. Thierry-Mieg - 19 Septembre 2005
10
Marriage
date
wife
Person
SS_num
husband
parent
Ancestor
child
Cardinality
Y. Thierry-Mieg - 19 Septembre 2005
11
0,1
0,N
1,N
R1
A1
A2
Entity
Occurrence
Cardinality (2)
Y. Thierry-Mieg - 19 Septembre 2005
12
Examples :
Entity
1,1
0,N
1,N
Occurrence
R
R1
A1
R2
A2
R1
A1
R2
A2
R1
A1
R2
A2
R3
13
Order
pass
0,N
Customer
Order
Order line
0,N
Item
Person
Marriage
0,1
Person
concern
1,1
Marriage
0,N
14
Faculty
Date
0,N
Year
0,N
0,N
Offer
Enroll
1,N
Student
SID
0,N
FID
0,1
1,1
Chair
Member
1,N
Course
1,N
Dept
Course_id
1,1
1,1
Dept_id
Organize
0,N
15
University :
Resulting Logical schema
Y. Thierry-Mieg - 19 Septembre 2005
16
organize
member
chair
Date(year)
Should be created by basic application of translation rules. In
practice, optimized away.
Optimization rule :
Any entity that has a single attribute may be removed from the
relational schema (i.e. no table)
SPORACT database
Y. Thierry-Mieg - 19 Septembre 2005
17
Facility
0,N
NUMF
NameF
AdrF
Cost
0,N
member
Date_insc
Practice
0,N
0,N
Offer
0,N
0,N
0,N
Actor
NUMA
NameA
LNameA
ADRA
Sport
Sport
DescSport
FACILITY(NUMF,NAMEF,ADRF,COST)
ACTOR(NUMA,NAMEA,LNAMEA,ADRA)
MEMBER(NUMA,NUMF,DATEINSC)
OFFERS(NUMF,SPORT)
PRACTICE(NUMA,NUMF,SPORT)
SPORT(SPORT, DESCSPORT)
19
schema :
Bottom-up : make a list of all basic data that should be stored in the
information system. Group them to form entities and/or associations.
Decomposition of entities
Y. Thierry-Mieg - 19 Septembre 2005
20
Basic problem :
isolated in an entity
At the other, all properties in a
single entity
Engineer
Engineer
CodeE
NameE
QualificationE
MaritalStatus
0,N
NameEngineer
NameE
1,1
1,1
0,N
QualificationE
CodeE
1,1
QualifEngineer
0,N
MaritalStatus
Status
10
Decomposition : Motivation
Y. Thierry-Mieg - 19 Septembre 2005
21
Stock
ID_I
ID_D
desc
qty
adr
price
cap
I1
D1
A1
21
200
I2
D1
A1
6,50
200
I1
D2
12
A2
21
150
CodeItem
CodeDepot
DescItem
QtyInStock
AdressDepot
ItemPrice
DepotCapacity
Data loss = update anomaly : when a depot is empty we lose its adress
!! when an item is out of stock we lose its description !!
22
Case 1 : Mandatory
A property that may take several values for an instance of the entity
E.g. children of a person, qualifications of an engineer
Engineer
CodeE
NameE
MaritalStatus
0,N
0,N
IsQualified
Software
SoftwareName
11
23
Case 2 : Mandatory
A property that has a single value at time t but which may evolve and
for which we wish to maintain a history
1,N
occupies
0,N
Position
PositionName
date
24
0,1
married
0,N
Spouse
SpouseName
12
25
1,1
order
CodeP
NameP
Name depends
on client code
0,N
Client
CodeClient
NameClient
26
Engineer
CodeE
NameE
MaritalStatus
1,1
occupies
0,N
Position
PositionName
13
Decomposition : Conclusion
Y. Thierry-Mieg - 19 Septembre 2005
27
Item
0,N
Stock 0,N
Qty
Depot
28
Example:
CodeItem -> DescItem
CodeItem -> ItemPrice
CodeDepot -> AddressDepot
CodeDepot -> DepotCapacity
CodeItem,CodeDepot -> QtyInStock
14
Which FD is satisfied?
Y. Thierry-Mieg - 19 Septembre 2005
29
A
A1
A1
A2
A2
A3
B
B1
B2
B2
B3
B3
C
C1
C1
C2
C2
C2
D
D1
D2
D2
D3
D4
A B,
A C,
C A,
A D,
B D,
AB D
30
15
Normal Forms
Y. Thierry-Mieg - 19 Septembre 2005
31
Example :
Offer(NumF,List of sports) : i.e. (101,{FOOT,BASKET,KART}) is
not 1NF
Offer(NumF,Sport) is 1NF :
(101,FOOT),(101,BASKET),(101,KART)
32
Stock
CodeItem
CodeDepot
DescItem
QtyInStock
AdressDepot
ItemPrice
DepotCapacity
Example:
CodeItem,CodeDepot -> DescItem
CodeItem,CodeDepot -> DepotCapacity
Are decomposable :
CodeItem -> DescItem
CodeDepot -> DepotCapacity
Not 2NF !!
16
33
and Y such that X->Z and Z->Y. We further suppose that Z->X
is false.
A relation is 3NF, if it is 2NF and the dependencies between the
key and the other attributes are elementary and direct.
Example:
Actor(NumA,NameA,BirthA,BirthTownA,BirthCountryA)
These DF are direct :
NumA -> NameA
NumA -> BirthA
NumA ->BirthTownA
BirthTownA -> BirthCountryA
NumA->BirthCountryA is not because:
BirthTownA -> BirthCountryA
Boyce Codd NF
Y. Thierry-Mieg - 19 Septembre 2005
34
17