Unit 1-Data Modeling Using Entity Relationship (E-R) Diagram
Unit 1-Data Modeling Using Entity Relationship (E-R) Diagram
Contents
• Simple
• Each entity has a single atomic value for the attribute. For example, SSN or
Gender.
• 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.
• Multi-valued
• 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
• 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 Designof Entity TypesfortheCOMPANY 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
• Relationship Type:
• Is the schema description of a relationship
• Identifies the relationship name and the participating entity types
constraints
• Relationship Set:
• The current set of relationship instances represented in the database
• The current state of a relationship type
DEPARTMENT)
• MANAGES (also between EMPLOYEE, DEPARTMENT)
• CONTROLS (between DEPARTMENT, PROJECT)
• WORKS_ON (between EMPLOYEE, PROJECT)
Discussion on RelationshipTypes
• 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
• 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
Weak EntityTypes
Constraints on Relationships
• Constraints on Relationship Types
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)
Many-to-Many(M:N) Relationship
Attributes of Relationship Types
• A relationship type can have attributes:
• For example, HoursPerWeek of WORKS_ON
• Its value for each relationship instance describes the number of
hours per week that an EMPLOYEE works on a PROJECT.
• A value of HoursPerWeek depends on a
particular (employee, project) combination
• Most relationship attributes are used with M:N relationships
• For M:N relationships, some attributes are determined by the
combination of participating entities, not by a single entity. Such
attributes must be specified as relationship attributes
• Read the min,max numbers next to the entity type and looking away from the entity type