Data Models
ER Model
E-R Model
• It stands for Entity Relationship Model.
• It is a detailed, logical representation of the data for an organization.
• It is the mainstream approach for conceptual data modeling.
• It is most often used as a communication tool between database designers and end users during
analysis phase of database development.
• It was proposed by Peter Chen in 1976 for conceptual database design
• The model has been subsequently extended in 1986 and 1991.
• It expresses logical representation for an organization in terms of Entities, Relationships among
Entities and Attributes of Entities and Relationship.
• It uses E-R Diagrams.
• E-R Diagram is a graphical representation of an E-R Model.
• The Basic Constructs of ER Model are:
ER Model – Basic Constructs
Entity
Strong Weak
Strong
Relationship
Attribute Multi valued
Gerund Associative
Entity
ER Model – Notations
ENTITY NAME
Identifier
Attribute
[Derived]
{Multivalued}
Composite( , , )
Data Model Basic Building Blocks
• Entity: Unique and distinct object used to collect and
store data
– Attribute: Characteristic of an entity
• Relationship: Describes an association among entities
– One-to-many (1:M)
– Many-to-many (M:N or M:M)
– One-to-one (1:1)
• Constraint: Set of rules to ensure data integrity
5
Entity
• An Entity is an Object, Event, Persons, Place or Concept about which the organization
wishes to maintain data.
• For Example: Doctor, Patient, Student, Faculty, room etc.
• An Entity is diagrammatically represented as
STUDENT
Attribute
• An attribute is a characteristic of an entity.
• For example, a CUSTOMER entity would be described by attributes
such
– customer last name,
– customer first name,
– customer phone,
– customer address,
– customer credit limit.
Relationship
• Relationship: Describes an association among entities
– One-to-many (1:M)
– Many-to-many (M:N or M:M)
– One-to-one (1:1)
Sample E-R Model
Sends SUPPLIER
Supplies
CUSTOMER
SHIPMENT Includes ITEM
Submits
Used_in
PRODUCT Requests ORDER
E-R Model
Degree of Relationship
• It refers to the number of entities participating in a relationship.
• There can be following types of relationships on the basis of degree:
a) Unary Relationship (relationship between the instances of a single entity type)
b) Binary Relationship (---- Two----)
c) Ternary Relationship (---- Three ----)
• The association (connectivity) between the entity instances can be:
a) One to One (1:1)
b) One to Many (1:M)
c) Many to Many (M:N)
E-R Model
Degree of Relationship
E-R Model
b) Binary Relationship
• It is a relationship between the instances of a two entity types.
• This is the most common type of relationship.
• The association types can be:
a) One to One Association.
b) One to Many Association.
c) Many to Many Association.
• Examples…..
c) Ternary Relationship
• It is a relationship between the instances of a three entity types.
• Example….
E-R Model
Cardinality of a Relationship
• It refers to the number of entity instances of one entity type that can be associated
with the number of entity instances of the other entity or same entity type.
• It assigns a specific value to connectivity.
• There are two types of cardinality:
a) Minimum Cardinality
b) Maximum Cardinality
• Cardinality of relationship is expressed as:
(min-card, max-card)
E-R Model
a) Minimum Cardinality
• It refers to the Minimum number of entity instances of one entity type that can be associated with the
number of entity instances of the other entity or same entity type.
• There are two types of it:
a) Mandatory Cardinality (Min Card=1)
b) Optional Cardinality (Min Card=0)
b) Maximum Cardinality
• It refers to the Maximum number of entity instances of one entity type that can be associated with the
number of entity instances of the other entity or same entity type.
• The combination of minimum and maximum cardinality gives rise to the following final combinations:
E-R Model
Cardinality Combinations
a) Mandatory One Cardinality
(Min Card=1, Max Card=1)
b) Mandatory Many Cardinality
(Min Card=1, Max Card=Many)
c) Optional One Cardinality
(Min Card=0, Max Card=1)
d) Optional Many Cardinality
(Min Card=0, Max Card=Many 1)
Relationship Participation
The Crow’s Foot Representation of the Invoicing Problem
Figure 4.64
Gerund / Associative Entity
Attributes of a Relationship
Gerund / Associative Entity
• A Gerund is a many to many relationship that is represented as an entity type.
• It is also called an entity in disguise or a Composite or Bridge Entity.
• Gerund is an entity derived from a relationship.
• It is represented by and Enclosed diamond symbol within entity box
• Example…..
Gerund – Example
Certificate_Number Date_Completed
Course_ID
Emploee_ID Employee_Name
EMPLOYEE CERTIFICATE COURSE
Course_Title Topic
Birth_Date
Associative Entity
Home work
• Draw an E-R Model for "Aqsa & Co" that is a Chartered Accountants Firm. Use the
following assumptions about the Human resources department.
• There are many departments of company having attributes of; Department Number,
Phone Number, Address etc.
• Each person in the organization is considered to be an employee including the owner.
Employee may or may not belong to a department.
• There are many employees in the organization with attribute of; Employee ID, Name,
Phone Number, Address, Hire-Date, Age, gender etc.
• An employee can go on leaves and leave has two types; Casual leave and Paid leave and
leaves have attributes; Leave Date, Leave Type, Number of days etc.
• The record of children of employees is also to be recorded. The attribute for the
children are; Children number, gender, Age, etc.
• Employees supervise projects running in the organization and each project has
attributes of; Project ID, Project Name, Start Date and Completion Date etc.
• Company has some Laboratories in it and every project is completed in some
Laboratory.