Escolar Documentos
Profissional Documentos
Cultura Documentos
Associations between instances of one or more entity types that is of interest
Given a name that describes its function.
• relationship name is an active or a passive verb.
Relationship name:
writes
Author Book
An author writes one or more books
A book can be written by one or more authors.
Constraints on Relationship
Types
Constraints limit the set of possible
combination of entities that can
participate in the relationship type
Two main kinds of constraints:
Cardinality constraints
Participation constraints
Cardinality Constrain
Crow’s Foot
One Mandatory one , means (1,1)
Partitipation constraint
many
One or many
Multiplicity of
Relationships
multiplicity of relationship in ER diagram represented by an
arrow pointing to “one”
Many to Many
Relationship
N N
customer custacct account
opening date
opening date
opening date
opening date
One to One Relationship
1 1
customer custacct account
opening date
Illegal
1 Customer Account Start Date
customer can John 1001 Jan 20th 1999
have 1 account. Megan 1001 March 16th 1999
1:M A car can have
car driver more than one driver; a
driver can only one car.
1:M A car can have only
car driver one driver; a driver can
have more than one car.
M:N A car can have more than
car driver one driver; a driver can have
more than one car.
Relationship
A typical company name
manages Managing
Company
Director
employs
take orders
Sales Staff Customer
Participation Constraints
total participation is also called
existential dependency
mandatory
If an entity does not have a total
participation in a relationship, it is
said to have a partial participation
optional
Mandatory vs. Optional Cardinalities
Specifies whether an instance must exist or can be
absent in the relationship
Mandatory Optional
handles
Lecturer Class
(1,1) (0,N)
M
1
Lecturer handles Class
(0,N) (1,1)
A Lecturer may handle zero or many classes.
A class is handled by one and only one Lecturer.
Degree of Relationships
1:M relationship
◦ Relational modeling ideal
◦ Should be the norm in any relational database design
The 1: M relationship between PAINTER and PAINTING
The Implemented 1:M relationship between PAINTER and PAINTING
Binary Relationships
1:1 relationship
◦ Should be rare in any relational database design
◦ A single entity instance in one entity class is related to
a single entity instance in another entity class
◦ Could indicate that two entities actually belong in the
same table
The 1:1 Relationship Between PROFESSOR and DEPARTMENT
The Implemented
1:1 Relationship
Between
PROFESSOR
and
DEPARTMENT
Binary Relationships
M:N relationships
◦ Must be avoided because they lead to data
redundancies.
◦ Can be implemented by breaking it up to
produce a set of 1:M relationships
◦ Can avoid problems inherent to M:N relationship
by creating a composite entity or bridge
entity
` This will be used to link the tables that were
originally related in a M:N relationship
` The composite entity structure includes-as
foreign keys-at least the primary keys of
The M:N Relationship Between STUDENT and CLASS
Bowser Accounting 1 (ACCT211)
Intro to Microcomputing (CIS220)
Smithson
Intro to Statistics (QM261)
This CANNOT be implemented as shown next…..
The tables have many redundancies!!
+ CLASS_CODE
CLASS_CODE
+ STU_NUM
Changing the M:N relationship to TWO 1:M relationships
The database designer has 2 main options to
define a composite table’s primary key:
either
use the combination of those foreign
keys or create a new primary key.
Foreign keys reference the primary keys in the
other tables of which it has a relationship with
Converting the M:N relationship into TWO 1:M relationships
How to Evaluate a Data Model?
A good data model has the following:
◦ Accuracy and completeness
◦ Non redundancy
◦ Enforcement of business rules
◦ Data Reusability
◦ Stability and Flexibility
◦ Communication Effectiveness
◦ Simplicity
Next ….
Enhanced/Extended ER model…
PR : A hospital in-patient
system
A hospital is organised into a number of
wards.
Each ward has a ward number and a
name recorded, along with a number of
beds in that ward.
Each ward is staffed by nurses.
Nurses have their staff number and name
recorded, and are assigned to a single
ward.
Each patient in the hospital has a patient
identification number, and their name,
address and date of birth are recorded.
Each patient is under the care of a single
consultant and is assigned to a single
ward.
Each consultant is responsible for a
Exercise on In-patient
system
1. State 4 entities for the system
giving a suitable identifier for each
entity.
2. Draw an entity-relationship
diagram to show the relationships
between the entities.
Semoga Bermanfaat,
Sekian dan Terimakasih