Entity–Relationship
Modeling
In this chapter you will learn:
• How to use Entity–Relationship (ER) modeling in
database design.
• The basic concepts associated with the Entity–
Relationship (ER) model, namely entities,
relationships, and attributes.
• A diagrammatic technique for displaying an ER
model using the Unified Modeling Language (UML).
• How to identify and resolve problems with ER
models called connection traps.
Entity Types
• A group of objects with the same properties,
which are identified by the enterprise as
having an independent existence
• They can be objects with a physical (or ‘real’)
existence or objects with a conceptual (or
‘abstract’) existence
Entity Representation
Staff Branch
Relationship Types
• A set of meaningful associations among entity
types
Branch HAS Staff
Relationship Representation
Degree of Relationship Type
• A binary relationship
• A ternary relationship
• A quaternary relationship
A binary relationship
A ternary relationship
A quaternary relationship
Recursive Relationship
• A relationship type where the same entity
type participates more than once in different
roles.
recursive relationship called Supervises
entities associated through two distinct
relationships called Manages and Has
Attributes
• A property of an entity or a relationship type.
• The set of allowable values for one or more
attributes (Attribute domain)
Simple and Composite Attributes
• Simple Attribute: an attribute composed of a
single component with an independent
existence.
• Composite attribute: an attribute composed of
multiple components, each with an
independent existence.
Single-Valued and Multi-Valued Attributes
• Single-valued attribute: an attribute that holds
a single value for each occurrence of an entity
type (Sex, etc).
• Multi-valued attribute: An attribute that holds
multiple values for each occurrence of an
entity type (Telephone_number)
Derived Attributes
• An attribute that represents a value that is
derivable from the value of a related attribute
or set of attributes, not necessarily in the
same entity type.
• TotalStaff, Age, etc
Keys
• Candidate Key, The minimal set of attributes
that uniquely identifies each occurrence of an
entity type.
• Primary Key, The candidate key that is
selected to uniquely identify each occurrence
of an entity type.
• Composite key, A candidate key that consists
of two or more attributes
Attribute representation
Entity Types
• Strong entity types, entity type that is not
existence-dependent on some other entity
type.
• Weak entity type, entity type that is existence-
dependent on some other entity type. Weak
entity types are sometimes referred to as child,
dependent, or subordinate entities and strong
entity types as parent, owner, or dominant
entities.
A strong entity type called Client and a
weak entity type
Attributes on Relationships
• Attributes can also be assigned to
relationships.
• To record the date the property was
advertised and the cost, we associate this
information with the Advertises relationship
as attributes called dateAdvert and cost
example of a relationship called Advertises with
attributes dateAdvert and cost.
Structural Constraints
• Multiplicity, the number (or range) of possible
occurrences of an entity type that may relate
to a single occurrence of an associated entity
type through a particular relationship.
Multiplicity
• One-to-One (1:1) Relationships
• One-to-Many (1:*) Relationships
• Many-to-Many (*:*) Relationships
• Multiplicity for Complex Relationships
• Cardinality and Participation Constraints
One-to-One (1:1) Relationships
The multiplicity of the Staff Manages
Branch one-to-one (1:1) relationship.
One-to-Many (1:*) Relationships
The multiplicity of the Staff Oversees
PropertyForRent one-to-many (1:*) relationship type
Aturan transformasi dari ER-Model ke
Struktur
• 1: M key pd sisi “1” di didupilkasi pada sisi
“M”
• M: N membentuk struktur baru dimana
attribut berasal dari relasi dan key attribute
dari sisi M dan N
• Multi value attributes, maka membentuk
struktur baru ?
Mahasiswa(Nim (Pk), nama, Kode (fk), KodeJ (fk),
KodeK(fk))
Agama(Kode (pk), Ket)
Jurusan (KodeJ, NamaJ)
Kewarganegaraan(KodeK, NamaKw)
1
NamaKw
Memiliki Kewarganegaraan
KodeK
m Ket
Mahasiswa m 1
Menganut
Agama
m
Nim Nama
Memilih
Kode
1
KodeJ NamaJ
Jurusan
Mahasiswa(Nim (Pk), nama)
Ruang(KodeR (Pk), NamaR)
Dosen(Nip, Namad)
Matakuliah(KodeM (Pk), ket)
Memrogram(TA, Smt, Nim (Fk), KodeM (Fk), KodeR (Fk), Nip(Fk))
Nama TA Smt
Nim
Ruang
Mahasiswa
m p
Memrogram
NamaR
Nip
KodeR
r n
Dosen
Matakuliah
NamaD Ket
KodeM
Dosen(Nip, fNama, lNama)
Pendidikan(KodeP, NamaP)
MemRiwayatPendidikan(Nip, KodeP, TahunMasuk, TahunSelesai)
Kepangkatan(KodeK, NamaK)
MemRiwayatKepangkatan(Nip, KodeK, TerMulaiTanggal)
Jabatan(KodeJ, NamaJ)
MemRiwayatJabatan(Nip, KodeJ, TanggalMulai, TanggalBerakhir)
• Mengambil (‘20202021’,’2’,’98001’, ‘IF104’,’01’)
• Mengambil (‘20202021’,’2’,’98001’, ‘IF103’,’01’)
Many-to-Many (*:*) Relationships
The multiplicity of the Newspaper Advertises
PropertyForRent many-to-many (*:*)
Multiplicity for Complex Relationships
Cardinality and Participation Constraints
• Cardinality Describes the maximum number of
possible relationship occurrences for an entity
participating in a given relationship type.
• Participation Determines whether all or only
some entity occurrences participate in a
relationship
Multiplicity described as cardinality and
participation constraints
Problems with ER Models
• Fan trap, where a model represents a
relationship between entity types, but the
pathway between certain entity occurrences is
ambiguous.
• Chasm trap, where a model suggests the
existence of a relationship between entity
types, but the pathway does not exist
between certain entity occurrences.
Fan Trap
Chasm
Chasm Trap