Title: Database 3: 13 9 2005 08:30 10:30
1Database 3 13 / 9 / 2005 0830 1030
2From miniworld to actual tables
3Miniworld
- We need a more down to earth term...
4ER-model Entity
- Objects, items, concepts and nouns
5ER-models Attribute
- Characteristic, adjective or descriptive
6ER-models Entity with attributes
DOB
Human
Hair colour
Length
7ER-models Relation
8ER-models Entity with relation
has
HUMAN
CAR
9ER-models Entity with relation and attributes
dob
length
year
has
HUMAN
CAR
model
sex
10ER-models Entity with relation and attributes
dob
length
year
has
HUMAN
CAR
since
model
sex
11ER-models Cardinality
0
n
has
CAR
HUMAN
12ER-models Strong versus weak entities
Atr1
Atr1
Atr1
key
Atr2
Atr2
13ER-models Identifying relation
PERSON
1
1
Is married to
14ER-Diagrams Composite attribute
NAP
NAME
ADDRESS
PLACE
FIRST NAME
FAMILY NAME
15ER-diagrams Multivaried attribute
TELEPHONE
16ER-diagrams Derived attribute
AGE
17ER-models Total participation
has
CAR
HUMAN
18ER-models structural constraint
(1,5) n
0
has
CAR
HUMAN
19EER-models
- To cover additional, more complex miniworlds, we
use Extended Entity-Relaition models - Generalization and specialization
20EER- Models Subclasses
Person
Client
Employee
21EER-models Disjoint subclass of specialization
Person
d
Man
Woman
22EER-models Partial disjoint
Person
d
Waiter
Cook
23EER-models Total overlapping
Person
o
Man
Woman
24EER-models Partial overlapping
Person
o
Waiter
Cook
25Pause
26From ER to Tables
ER-model
Tables
27First step definition of the miniworld
- Mapping of regular entity types
- Mapping of weak entity types
- Mapping of binary 11 relations
- Mapping of binary 1 n relations
- Mapping of binary MN relations
- Mapping of multivalued relations
- Mapping of N-arry relationship types
- Think of a rule to map generalization
28Step 1 Mapping of Regular Entities
- For each strong entity create a (relation) with
all attributes. - Composite attributes should be considered as
separate attributes - Choose any of the key attribute as the primary
key - The other keys should be secondary keys
29Step 2 Mapping of weak entity types
- Create a relation for each weak entity with all
attributes - Include the key for the relating strong entity as
the key attribute - If the owner is weak, this should be mapped first
30Step 3 Mapping of binary 11 relationship
- Create a relation for each relation
- Foreign key approach. Choose on of the entities
of the relation and add all the attributes of the
other - Merged relation. Both entities are merged into
one relation - Cross reference a relation of both keys
31Step 4 Mapping of binary 1N relations
- Include the key of the entity at the 1-side of
the relations in the entity at the n-side
32Step 5 Mapping of binary MN relations
- Create a new relation with bot primary keys
33Step 6 Mapping of multi valued attributes
- For each multivalued attribute create a new
relation
34Step 7 Mapping of n-ary relations
- All keys of the relating entities ends up in one
relation
35Step 8 Mapping subclasses