Unit 1-Data Modeling using Entity Relationship (E-R) Diagram.docx
Unit 1-Data Modeling using Entity Relationship (E-R) Diagram.docx
Contents
ER
implementation
of db, relational
data model
operations
• Entities are specific objects or things in the mini-world that are represented in
the database.
• For example the EMPLOYEE John Smith, the Research DEPARTMENT,
the ProductX PROJECT
• Attributes are properties used to describe an entity.
• For example an EMPLOYEE entity may have the attributes Name, SSN,
Address, Gender, BirthDate
• A specific entity will have a value for each of its attributes.
• For example a specific employee entity may have Name='John Smith',
SSN='123456789', Address ='731, Fondren, Houston, TX', Gender='M',
BirthDate='09-JAN-55‘
• Each attribute has a value set (or data type) associated with it – e.g. integer,
string, subrange, enumerated type, etc
Types of Attributes
• Simple
• Each entity has a single atomic value for the attribute. For example, SSN or
Gender.
• Composite
• An entity may have multiple values for that attribute. For example, Color of
a CAR or PreviousDegrees of a STUDENT.
• Denoted as {Color} or {PreviousDegrees}.
• Each entity type will have a collection of entities stored in the database
• Called the entity set (also called the
• Same name (CAR) used to refer to both the entity type and the entity set
• Entity set is the current state of the entities of that type that are stored in the database
• Each simple attribute is associated with a value set (or domain of values)
• Ex. The Age attribute of EMPLOYEE to be the set of integer numbers
between 16 to 70
Initial Design of Entity Types for the COMPANY Database Schema
• Based on the requirements, we can identify four initial entity types in the COMPANY
database:
• DEPARTMENT
• PROJECT
• EMPLOYEE
• DEPENDENT
• Their initial design is shown on the following slide
• The initial attributes shown are derived from the requirements description
EMPLOYEE WORKS_ON
PROJECT
• Relationship Type:
• Is the schema description of a relationship
• Identifies the relationship name and the participating entity types
• Also identifies certain relationship
constraints
• Relationship Set:
• The current set of relationship instances represented in the database
• The current state of a relationship type
• In ER diagrams, we represent the
DEPARTMENT)
• In the refined design, some attributes from the initial entity types are refined into
relationships:
• Manager of DEPARTMENT -> MANAGES
• Works_on of EMPLOYEE -> WORKS_ON
• Department of EMPLOYEE -> WORKS_FOR
• etc
• In general, more than one relationship type can exist between the same participating
entity types
• MANAGES and WORKS_FOR are distinct relationship types between
EMPLOYEE and DEPARTMENT
• Different meanings and different relationship instances.
• Each entity type that participates in a relationship type plays a particular role in the
relationship
Recursive Relationship Type
• A relationship type where the same entity type participates more than once in the
relationship in distinct roles is called recursive relationship
• Example: the SUPERVISION relationship
• EMPLOYEE participates twice in two distinct roles:
supervises
Constraints on Relationships
• Constraints on Relationship Types
• Cardinality Ratio (specifies maximum
participation)
• One-to-one (1:1)
• One-to-many (1:N) or Many-to-one (N:1)
• Many-to-many (M:N)
• Existence Dependency Constraint (specifies minimum participation) (also
called participation constraint)
• zero (optional participation, not existence- dependent)
• one or more (mandatory participation, existence-dependent)
• Read the min,max numbers next to the entity type and looking away from the entity type