Chapter3 ERD1

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 42

Chapter Three

What is a Model?
A hypothetical description of a complex entity or
process
A model is a representation of something in our
environment
Features of a Model
Mapping - A model is based on something
original.
Reduction - A model only reflects a (relevant)
selection of the original's properties.
Pragmatic - A model needs to usable in place
of the original with respect to some purpose.
What is a Data Model?
A set of concepts to describe
structure of a database
operations for manipulating these structures
certain constraints that the database should
obey.
Entity Relationship Model
It provides a set of constructs used to
interpret, specify and document logical data
requirements for database processing
systems.
ER model is a conceptual data model that
views the real world as
entities and
relationships among entities
Entity Relation Model
What are the entities and relationships in the
enterprise?
What information about these entities and
relationships should we store in the
database?
What are the integrity constraints or business
rules that hold?
ER Model Concepts
Entity types
Attributes
Relationship types
Entity
Recognizable concepts, either concrete or
abstract, such as person, places, things, or events
which have relevance to the database.
Entities are specific objects or things in the mini-
world that are represented in the database
An object or concept that is uniquely identifiable.
An object that exists and is distinguishable from
other objects.
Entities - Examples
the EMPLOYEE Mohammad Ali
the Computer Science DEPARTMENT,
the Database-I COURSE.
Attributes
Attributes are properties used to describe an
entity i.e. Entities have attributes
Examples
An EMPLOYEE entity may have
EmployeeID, Name, DateOfBirth, Address,
Gender
A Course entity may have
CourseCode, CourseTitle, Credit
Attributes and Values
 A specific entity will have a value for each of its
attributes
 Examples:
 A specific Employee entity may have
EmployeeID=1234
Name=‘Mohammad Ali’
DateOfBirth=12-09-1970
Address= House 12, Islamabad
Gender=Male
 A specific course entity may have
Course Code: 3410
CourseTitle: Database-I
Credit=3
Attributes and Values
Attribute Domain
Each attribute has a value set (or data type
or a set of permitted values), called attribute
domain, associated with it
Examples:
 integer, string, sub-range, enumerated type
etc.
Range of ages allowed for employee is between
16 and 70, and range of grades: A,A-, B+,B,B,
C+,C,C-,D+,D,F.
Types of Attributes
Simple
Attribute that holds a single value for an entity
For example
 Age (36 years)
 Gender (Male or Female)

 CPR-NO
Types of Attributes
Composite
The attribute may be composed of several
components. For example, Address (Apt#,
House#, Street, City, State, ZipCode, Country)
or Name (FirstName, MiddleName, LastName).
Composition may form a hierarchy where some
components are themselves composite.
Types of Attributes
Types of Attributes
Multi-valued
Attribute that holds multiple values for an
entity
An entity may have multiple values for an
attribute.
For example
 Color of a CAR
 PreviousDegrees of a STUDENT
Types of Attributes
Stored Attribute
Attribute whose value is actually stored in the
database. For example DateOfBirth
Derived Attribute
Attribute that represents a value that is
derivable from value of a related attribute, or
set of attributes, not necessarily in the same
entity type. For example Age of an Employee
entity can be derived from his DateOfBirth
Key Attribute
Uniquely identifies each occurrence of an
entity type.
Student Registration No
ID Card Number
Course Code
Key attribute can be
Simple
Composite
Entity Type
Entities with the same basic attributes are
grouped or typed into an entity type
Entity Set
The collection of all entities of a particular entity
type (i.e. all entities in an entity set have the
same set of attributes) in the database at any
point in time is called an entity set.
All entities in an entity set have the same set of
attributes.
Both Entity type and entity set are referred with
same name, employee entity type or employee
entity set.
Entity Type
A collection of similar entities
Examples:
A set of ALL EMPLOYEE entities
A set of ALL Course entities
Entity Type and Entity Set
STUDENT
(RegNo, Name, gender, DateOfBirth, Major)

Student 1
(12324, Ali Hassan, Male, 12-Jan-1995, Computer Science)
Student 2
(56789, Ameera Ali, Female, 21-July-1999, Chemistry)
Student 3
(43256, Gul Ahmed, Male, 9-Mar-1991, Computer Science)
:
Entity Type and Entity Set
Weak Entity Types
Weak entity meets two conditions
 Existence-dependent on identifying entity
 it must relate to the identifying entity set via a total,
one-to-many relationship set from the identifying to the
weak entity set
 Primary key partially or totally derived from parent
entity in relationship. Weak entities are identified by
the combination of:
 A partial key of the weak entity type
 The particular entity they are related to in the
identifying entity type
Database designer determines whether an
entity is weak based on business rules
Weak Entity Types
Weak Entity Types
EMPLOYEE and DEPENDENT
A driver_license entity cannot exist unless it
is related to a person entity
Regular or Strong Entity Type
An entity type that is not existence
dependant on some other entity type is called
strong or regular entity type
Relationship
relates two or more distinct entities with a
specific meaning or a meaningful association
among entity types.

EMPLOYEE Ali WORKS in CS Dept


EMPLOYEE Mohammad WORKS in Arts Dept

CUSTOMER Nisar DEPOSITS money in


ACCOUNT A-01
Relationship Types
Relationships of the same type are grouped
or typed into a relationship type.
Relationship types are typically given names.
Relationship types and relationship set are
referred to by the same name.
Relationship Types
Relationship Types
Degree of Relationship
The degree of a relationship is the number of
entities that participate in the relationship.
Relationships of degree 2 are called binary
relationships.
 Most relationships in databases are binary.
Degree of Relationship

A binary relation

A ternary relation
Cardinality of Relationship
Relationship Cardinality refers to the number
of entity instances involved in the
relationship.

one CUSTOMER may place many CUSTOMER


ORDERS
many STUDENTS may sign up for many
CLASSES
one EMPLOYEE receives one PAYCHECK
Constraints on Relationship Type:
Ratio constraint
Also known as (cardinality) ratio
constraints
Cardinality ratio determines the number
of possible relationships for each
participating entity
One-to-one (1:1)
One-to-many (1:N) or Many-to-one (N:1)
Many-to-many (N:M)
A 1:1 Relationship
A 1:n Relationship
A n:m Relationship
Participation Constraints
Participation constraints determine whether the
existence of an entity depends upon its being
related to another entity through a relationship.
Total Participation (or Existence Dependency or
mandatory participation): The entity's existence
requires the existence of an associated entity in a
particular relationship type.
Partial Participation (optional participation):
Participation is OPTIONAL if one entity occurrence
does not require a corresponding entity occurrence
in a particular relationship (not existence-
dependent.)
Recursive Relationship
Relationship type where same entity type
participates more than once in different roles.
Relationships may be given role names to
indicate purpose that each participating entity
type plays in a relationship.
Attributes of a Relationship Type
A relationship type can have attributes.

You might also like