2 Entity Relationship Model

Database Management System · Unit 2

Entity-Relationship Model

Exam-focused notes for Entity-Relationship Model (Database Management System, BIT202): what the TU syllabus asks and how it has actually been tested, with 7 solved past questions from this unit.

Entity-Relationship Model in short

The Entity-Relationship (ER) model is a way to draw the design of a database before building it. It shows the real-world things to store and how they connect. A clear ER diagram makes the later table design easy.

Entity-Relationship Model: notes

ER diagram purpose and symbols

An ER diagram is a picture of the conceptual design of a database. It helps designers and users agree on the data before any table is made. It is also a good communication tool.

SymbolMeaning
RectangleEntity set
Double rectangleWeak entity set
EllipseAttribute
Double ellipseMultivalued attribute
Dashed ellipseDerived attribute
Ellipse with underlined nameKey attribute
DiamondRelationship set
Double diamondIdentifying relationship of a weak entity
LineLink between entity and attribute or relationship
Double lineTotal participation
Triangle (ISA)Specialization or generalization

Entities and attributes

An entity is a real-world object that can be told apart from other objects, such as a student, a book, or a car. An entity set is a group of entities of the same type, such as all students.

An attribute is a property of an entity. For example, the entity Student has attributes RollNo, Name, and Phone. The key attribute uniquely identifies each entity. RollNo is a key, because no two students share it.

Each attribute takes values from a domain, which is the set of allowed values.

Attribute types and derived attributes

TypeMeaningExample
Simple (atomic)Cannot be split furtherAge, RollNo
CompositeCan be split into partsName into First, Middle, Last
Single-valuedOne value per entityDateOfBirth
MultivaluedMany values per entityPhoneNumbers
DerivedComputed from another attributeAge from DateOfBirth
KeyUniquely identifies the entityRollNo
NullValue unknown or not applicableMiddleName

A derived attribute is not stored. It is calculated when needed. It is drawn with a dashed ellipse. If the date of birth is stored, the age can be found by subtracting it from today's date.

What this unit covers

  • ER diagram purpose and symbols
  • Entities and attributes
  • Attribute types and derived attributes
  • Relationships and cardinality
  • Weak entities and partial keys
  • Generalization and specialization
  • Extended ER model constraints

ER diagram purpose and symbols

2082 · 10 marks

What is the need for an ER diagram? Design an ER diagram that contains at least five entities. One of the entities must be a weak entity. There should be many to many relationships between the two strong entities. One of the entities should have derived and multi-valued attributes. Any one strong entity should have total participation in a relationship with another entity. Use your own assumptions as per required.[10]

Show solved answer

ER Diagram: Need and Design


Part 1: Need for an ER Diagram (3 marks)

An Entity-Relationship (ER) Diagram is a high-level conceptual data model that graphically represents the structure of a database. The need for an ER diagram arises due to the following reasons:

  1. Visual Representation of Data: It provides a clear, pictorial view of the database structure, making it easy to understand the relationships among data entities before actual implementation.

  2. Communication Tool: It serves as a common language between database designers, developers, and non-technical stakeholders (clients, managers) to discuss and validate requirements.

  3. Blueprint for Database Design: It acts as a blueprint for translating the conceptual model into a logical and then physical database schema (tables, keys, constraints).

  4. Error Detection at Early Stage: Design flaws, redundancies, and missing relationships can be identified and corrected at the design stage, saving time and cost during implementation.

  5. Documentation: It serves as permanent documentation of the database structure for future maintenance and modification.

  6. Simplifies Complex Systems: For large and complex systems, ER diagrams break down the system into manageable entities and relationships, making design systematic and organized.


Part 2: ER Diagram Design (7 marks)

Assumptions / Scenario: University Management System


Entities and Their Attributes

EntityTypeAttributes
STUDENTStrongStudentID (PK), Name, Address, Age (derived from DOB), Phone (multi-valued), DOB
COURSEStrongCourseID (PK), CourseName, Credits
DEPARTMENTStrongDeptID (PK), DeptName, Location
PROFESSORStrongProfID (PK), ProfName, Salary
DEPENDENTWeakDepName (partial key), Relationship, Age -- depends on PROFESSOR

Relationships

RelationshipEntities InvolvedCardinalityParticipation
ENROLLSSTUDENT -- COURSEMany-to-Many (M:N)Partial both sides
BELONGS_TOSTUDENT -- DEPARTMENTMany-to-OneTotal (STUDENT), Partial (DEPARTMENT)
TEACHESPROFESSOR -- COURSEOne-to-ManyPartial both sides
WORKS_INPROFESSOR -- DEPARTMENTMany-to-OnePartial both sides
HAS_DEPENDENTPROFESSOR -- DEPENDENTOne-to-ManyPartial (PROFESSOR), Total (DEPENDENT -- weak entity)

Special Requirements Checklist

RequirementFulfilled By
At least 5 entitiesSTUDENT, COURSE, DEPARTMENT, PROFESSOR, DEPENDENT
One weak entityDEPENDENT (depends on PROFESSOR; identified by DepName + ProfID)
Many-to-Many relationshipSTUDENT ENROLLS COURSE
Derived attributeAge (derived from DOB) in STUDENT
Multi-valued attributePhone in STUDENT
Total participationSTUDENT totally participates in BELONGS_TO (every student must belong to a department)

ER Diagram (Text/Notation Representation)

                    [DOB]  ((Phone))  [Name]  [Address]
                      |       |         |        |
                    (Age*)    |         |        |
                      \       |         |        /
                       ======[STUDENT]======
                      /                      \
              (double line)                   \
                  ||                           \
           <BELONGS_TO>                    <ENROLLS> (M:N)
                  |                             |
           [DEPARTMENT]                      [COURSE]
           DeptID, DeptName,              CourseID, CourseName,
           Location                       Credits
                                               |
                                          <TEACHES>
                                               |
                                         [PROFESSOR]
                                    ProfID, ProfName, Salary
                                        /           \
                                  <WORKS_IN>    <HAS_DEPENDENT>
                                       |               || (double line)
                                 [DEPARTMENT]    [[DEPENDENT]]
                                              DepName(dashed underline),
                                              Relationship, Age

ER Diagram (Formal Diagram Description)

+------------------------------------------------------------------+
|                  UNIVERSITY MANAGEMENT SYSTEM                    |
+------------------------------------------------------------------+

  [DOB]  ((Phone))  [Name]  [Address]
    |        |         |       |
  (Age*)     |         |       |
    +--------+---------+-------+
    |                          |
 ====[  STUDENT  ]====         |
 ||  StudentID(PK)  ||         |
 ||  Name, Address  ||         |
 ||  DOB            ||         |
 ||  Age*           ||         |
 ||  {Phone}        ||         |
 ====                ====      |
  |                    |       |
  | (Total)            |       |
  |                    |       |
<BELONGS_TO>      <ENROLLS> (M:N)
  |                    |
  |              [  COURSE  ]
[DEPARTMENT]     CourseID(PK)
DeptID(PK)       CourseName
DeptName         Credits
Location              |
  |              <TEACHES>
  |                   |
<WORKS_IN>----[PROFESSOR]----<HAS_DEPENDENT>
              ProfID(PK)              ||
              ProfName           [[DEPENDENT]]
              Salary             DepName (partial key, dashed underline)
                                 Relationship
                                 Age

Notation Key

SymbolMeaning
[ ]Entity (Rectangle)
`[[ ]]Weak entity (double rectangle)
( )Attribute (ellipse)
(( ))Multi-valued attribute (double ellipse)
( * )Derived attribute (dashed ellipse)
< >Relationship (diamond)
<< >>Identifying relationship (double diamond)
==== or a double lineTotal participation
A single linePartial participation
UnderlinePrimary key
Dashed underlinePartial (discriminator) key of a weak entity

Cardinality Summary

RelationshipParticipating entitiesCardinalityRemark
BELONGS_TOSTUDENT, DEPARTMENTM:1Total on the STUDENT side, every student belongs to exactly one department
ENROLLSSTUDENT, COURSEM:NA student takes many courses and a course is taken by many students
TEACHESPROFESSOR, COURSE1:NEach course is taught by one professor, a professor may teach several
WORKS_INPROFESSOR, DEPARTMENTM:1Each professor is attached to one department
HAS_DEPENDENTPROFESSOR, DEPENDENT1:N identifyingDEPENDENT is weak, it has no key of its own and is identified by ProfID together with DepName

The M:N relationship ENROLLS cannot be represented by a foreign key in either table, so on conversion to tables it becomes a separate relation ENROLLMENT(StudentID, CourseID, Grade) whose primary key is the pair of foreign keys. The weak entity DEPENDENT likewise becomes DEPENDENT(ProfID, DepName, Relationship, Age) with ProfID as both part of the primary key and a foreign key, deleted along with its owner professor.


Conclusion

An ER diagram is needed because it captures the structure of the data, the entities, their attributes and the relationships among them, before any table is written, and it does so in a notation that a non technical user can still read and approve. The design above satisfies the requirements of the question: five entities (STUDENT, DEPARTMENT, COURSE, PROFESSOR and the weak entity DEPENDENT), a many to many relationship between the two strong entities STUDENT and COURSE, a derived attribute (Age, computed from DOB) and a multi-valued attribute (Phone) on STUDENT, and total participation of STUDENT in BELONGS_TO.

Open this answer on its own page →

2079 · 10 marks

Explain the various Symbols used in E-R Model?[10]

Show solved answer

Symbols Used in E-R Model

Introduction

The Entity-Relationship (E-R) Model is a high-level conceptual data model used to describe the structure of a database. It was proposed by Peter Chen in 1976. The E-R model uses a set of standard graphical symbols to represent data and the relationships among data. An E-R diagram (ERD) is a diagrammatic representation using these symbols.


Standard Symbols Used in E-R Model

1. Rectangle ( Entity )

+------------------+
|     STUDENT      |
+------------------+
  • A rectangle represents an Entity or Entity Set.
  • An entity is a real-world object or thing that has an independent existence and can be distinctly identified.
  • Example: STUDENT, EMPLOYEE, DEPARTMENT, COURSE

2. Double Rectangle ( Weak Entity )

+==================+
||  DEPENDENT     ||
+==================+
  • A double rectangle represents a Weak Entity Set.
  • A weak entity is one that cannot be uniquely identified by its own attributes alone; it depends on a strong (owner) entity for its existence.
  • Example: DEPENDENT (depends on EMPLOYEE), ORDER-ITEM (depends on ORDER)

3. Ellipse / Oval ( Attribute )

      (  Name  )
  • An ellipse (oval) represents an Attribute.
  • An attribute is a property or characteristic that describes an entity.
  • Example: Name, Age, Salary, Address

4. Double Ellipse ( Multivalued Attribute )

    ((  Phone  ))
  • A double ellipse represents a Multivalued Attribute.
  • A multivalued attribute can hold more than one value for a single entity instance.
  • Example: Phone_Number (a person can have multiple phone numbers), Skills

5. Dashed Ellipse ( Derived Attribute )

    (- - Age - -)
  • A dashed (dotted) ellipse represents a Derived Attribute.
  • A derived attribute is one whose value can be computed or derived from other attributes.
  • Example: Age (derived from Date_of_Birth), Total_Salary (derived from Basic + Allowances)

6. Ellipse with Underlined Text ( Key Attribute )

    ( <u>Roll_No</u> )
  • An ellipse with the attribute name underlined represents a Key Attribute (Primary Key).
  • A key attribute uniquely identifies each entity in an entity set.
  • Example: Roll_No for STUDENT, Emp_ID for EMPLOYEE

7. Dashed Underline ( Partial Key )

    ( - - Dep_Name - - )
  • An attribute with a dashed underline represents a Partial Key (Discriminator).
  • It is used for weak entities; it can uniquely identify weak entities only when combined with the key of the owner entity.
  • Example: Dependent_Name in DEPENDENT entity

8. Diamond ( Relationship )

        < ENROLLS >
  • A diamond shape represents a Relationship Set.
  • A relationship describes how two or more entities are associated with each other.
  • Example: ENROLLS (between STUDENT and COURSE), WORKS_FOR (between EMPLOYEE and DEPARTMENT)

9. Double Diamond ( Identifying Relationship )

       << HAS >>
  • A double diamond represents an Identifying Relationship.
  • It connects a weak entity to its owner (strong) entity.
  • Example: HAS (between EMPLOYEE and DEPENDENT)

  • Lines are used to connect:
    • Entities to their attributes
    • Entities to relationships
  • They show the participation and association between components.

11. Double Line ( Total Participation )

STUDENT ======= < ENROLLS >
  • A double line between an entity and a relationship indicates Total Participation.
  • Every entity in the entity set must participate in at least one relationship instance.
  • Example: Every EMPLOYEE must work for a DEPARTMENT.

12. Single Line ( Partial Participation )

STUDENT ------- < ENROLLS >
  • A single line indicates Partial Participation.
  • Not every entity needs to participate in the relationship.
  • Example: Not every STUDENT may enroll in every COURSE.

13. Cardinality Notations on Lines

Cardinality ratios are written on the lines to indicate the number of entity instances participating in a relationship:

NotationMeaning
1 : 1One-to-One
1 : NOne-to-Many
M : NMany-to-Many
  • Example: One DEPARTMENT has many EMPLOYEEs (1:N)

Summary Table

SymbolShapeRepresents
RectangleSingle boxEntity Set
Double RectangleDouble boxWeak Entity Set
EllipseSingle ovalAttribute
Double EllipseDouble ovalMultivalued Attribute
Dashed EllipseDotted ovalDerived Attribute
Ellipse (underlined)Oval + underlineKey Attribute
Dashed underlineDotted underlinePartial Key
DiamondSingle diamondRelationship Set
Double DiamondDouble diamondIdentifying Relationship
Single LineThin linePartial Participation / Link
Double LineThick/double lineTotal Participation

Conclusion

The E-R model symbols provide a standardized, visual way to design and communicate database structure. Each symbol has a precise meaning, and together they allow database designers to represent entities, their attributes, and the relationships among them clearly before actual implementation in a DBMS.

Open this answer on its own page →

2078 · 5 marks

What is an E-R Diagram? Explain various symbols used in the E-R Diagram.[5]

An Entity-Relationship (E-R) Diagram is a graphical/pictorial representation of the logical structure of a database. It shows the entities (objects) in a system, the attributes of those entities, and the relationships between them. It was introduced by Peter Chen in 1976 and is widely used as a t...

Open this answer on its own page →

Extended ER model constraints

2082 · 5 marks

Discuss the various types of constraints used on Extended ER Model. [5]

The Extended Entity-Relationship (EER) model adds additional semantic concepts to the basic ER model. Among the most important additions are constraints on specialization and generalization, which control how entities participate in subclass/superclass relationships. --- This constraint specifies...

Open this answer on its own page →

Attribute types and derived attributes

2080 · 5 marks

What is Attributes? Explain different types of Attributes with example. [5]

An attribute is a property or characteristic that describes an entity in an Entity-Relationship (ER) model. Attributes represent the data stored about an entity and are depicted as ovals in an ER diagram. Example: For an entity STUDENT, attributes can be RollNo, Name, Age, Address. --- An attribu...

Open this answer on its own page →

Weak entities and partial keys

0 · 10 marks

What do you mean by weak entity and partial key?Design an ER diagram for following scenario; In film industry, producers produce movies. Producers have their name, age and budget as attributes. They are uniquely identified by prod_id. All the movies have their title, year, and release date. No movies can have same title. Every movies must be played by actor. An actor can play many movies. Actors have Fname and Lname to uniquely identify them. The actors have charge_rate as well. A single movie can have many producers and a producer can produce many movies.[3+7]

--- (a) Weak Entity and Partial Key A weak entity is an entity type that does not have a key attribute of its own. It cannot be uniquely identified by its own attributes alone. A weak entity depends on another entity (called the identifying entity or owner entity) for its existence and identifica...

Open this answer on its own page →

Generalization and specialization

0 · 5 marks

What do you mean by generalization specialization in EER? Illustrate with examples. [5]

The EER model extends the basic ER model with additional concepts to represent more complex real-world situations. Generalization and Specialization are two complementary processes used to organize entities into hierarchies. --- Specialization is a top-down process of defining subclasses from a s...

Open this answer on its own page →