Entity - Relationship-Diagram
Entity - Relationship-Diagram
relation tuple
Entity-Relationship diagram
The domain for ‘year’ might be the range of
years when films have been made; the domain
for title ‘title’ might be ‘character’, size 30.
Entity-Relationship diagram
Key attributes
It may be necessary to specify one or more of the
attributes of an entity as a “key” of the entity;
this particularity true of the relational model.
Three 3 types of keys are defined here:
Primary key(PK)
Candidate key selected to identify tuples uniquely within
relation.
Foreign key
is an attribute in a relation which is also the primary key in
another relation
Secondary Key
it is a field or combination of fields that can be used to access
or retrieve records. It can also be used to sort or display records in
a certain order.
Entity-Relationship diagram
Example
An entity product may be describes by its name and its
associated attribute.
SG6 R1 B001
SG35
SL20 R2 B002
Figure 1
One-to-One Relationship
Staff Branch
Multiplicity
Entity-Diagram Relationship
One –to many relationship
customer order
places
customer no order no
1..1 0..*
Always start with the word “one”
Here an occurrence of the first entity type may be related to
several occurrences of the second, but each occurrence of the
second is related to a maximum of one occurrence of the first.
For the reading: One customer places zero or more orders; One
order is placed by one customer.
Entity-Diagram Relationship
Many –to many relationship
depot product
HeldAt
Depot no Product no
1..* 0..*
Always start with the word “one”
Here an occurrence of the first entity type may be related to
several occurrences of the second and vice versa.
For the reading: one depot holds zero or more products; one
product is held at 1 or more depots.
Entity –Relationship Diagram
Decomposition
All many -to -many relationship, can be
decomposed into two one-to-many
relationships.
One reason for doing this is that relational DBMSs
do not support many-to-many relationship
directly. Also, by eliminating many-to-many
relationships, problems in the model become
easier to spot.
Entity-Relationship diagram
Decomposition example