ch05 PDF
ch05 PDF
4
Main constructors of ER
– Data entities
– Relationships
– Attributes
ER Model Basics
• Entity: Real-world object distinguishable
from other objects. An entity is described (in
DB) using a set of attributes.
• An entity is shown in a rectangle.
• Entity Set: A collection of similar entities.
E.g., all employees.
– All entities in an entity set have the same set of
attributes. (Until we consider ISA hierarchies,
anyway!)
Entities
• Examples of entities:
– Person: EMPLOYEE, STUDENT, PATIENT
– Place: STORE, WAREHOUSE
– Object: MACHINE, PRODUCT, CAR
– Event: SALE,REGISTRATION, RENEWAL
– Concept: ACCOUNT, COURSE
• Guidelines for naming and defining entity types:
– An entity type name is a singular noun
– An entity type should be descriptive and specific
– An entity name should be concise
– Event entity types should be named for the result of the event, not the
activity or process of the event.
An entity’s name should be:
• Unique in the entire organization; furthermore, try to avoid similar
names for different entities, such as PROJECT and PROJECTION.
PROJECT PROJECTION
If different terms are used to define the same thing under
different departments synonyms can be defined. For example,
some departments may call it a CUSTOMER while others may
call a CLIENT.
Is its name a noun? Not all nouns represent entities, but all entity
names should be nouns.
Validate Entities
For example, if you think you have an entity named STUDENT, do you
need to store facts about students?
Name, Student Number, Address, Birth Date ....
YES, IT IS AN ENTITY.
Validate Entities
If you think you have an entity called CUSTOMER NAME, ask the
same question: Does it have any facts, attributes to store? The
country of origin, number of wovels, meaning of the name ....
Are these really important facts to store in your database?
• this key does not allow null values and also does
not allow duplicate values.
Relationship name:
writes
Author Book
• Chen Model
1
– 1 to represent one.
– M to represent many M
• Crow’s Foot
One Mandatory one , means (1,1)
many
One or many
Cardinality Ratio
b2 b1
E1 R E2
Man Woman
One-to-many (1:n)
Customer Order
Many-to-many (n:m)
Course Subject
1 1
HeadOfSchool Manages School
HOS
total partial
Question for you
• Cardinality ratio and participation constraint are together
called structural constraint
• Cardinality ratio can be either 1 : 1, 1 : N, or M : N
• participation constraint can be either total or partial
• How many different structural constraints are there:
– 2
– 4
– 8
– 12
Participation: Full/Partial
• It is likely that on any campus, not all students will drive an automobile
Lecturer
Instances of the SPL relationship type are triples (s, c, l ). The structural
constraints are determined by considering associations between:
• a (s, c ) pair and a l to determine cardinality ratio next to Lecturer, and
between a l and a (s, c ) pair to determine the participation constraint
of the Lecturer
• the same applies to a (s, l ) pair and a c for a Course instance, and a
•(l, c ) pair and a s for a Student instance
Relationships of the Degree > 2
N N
Student SPL Course
Lecturer
Suppose each Course c is taught by only one lecturer l and each lecturer
teaches at least one Course. Then:
• each (s, c ) pair is associated with exactly one l, so the cardinality
ratio next to Lecturer will be 1, and the Lecturer has a total participation
constraint,
• it is natural to expect that each (l, c ) pair is associated with zero or more
than one students, and
• each (s, l ) pair with zero or more than one Course