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.
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 answerHide 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:
-
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.
-
Communication Tool: It serves as a common language between database designers, developers, and non-technical stakeholders (clients, managers) to discuss and validate requirements.
-
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).
-
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.
-
Documentation: It serves as permanent documentation of the database structure for future maintenance and modification.
-
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
| Entity | Type | Attributes |
|---|---|---|
| STUDENT | Strong | StudentID (PK), Name, Address, Age (derived from DOB), Phone (multi-valued), DOB |
| COURSE | Strong | CourseID (PK), CourseName, Credits |
| DEPARTMENT | Strong | DeptID (PK), DeptName, Location |
| PROFESSOR | Strong | ProfID (PK), ProfName, Salary |
| DEPENDENT | Weak | DepName (partial key), Relationship, Age -- depends on PROFESSOR |
Relationships
| Relationship | Entities Involved | Cardinality | Participation |
|---|---|---|---|
| ENROLLS | STUDENT -- COURSE | Many-to-Many (M:N) | Partial both sides |
| BELONGS_TO | STUDENT -- DEPARTMENT | Many-to-One | Total (STUDENT), Partial (DEPARTMENT) |
| TEACHES | PROFESSOR -- COURSE | One-to-Many | Partial both sides |
| WORKS_IN | PROFESSOR -- DEPARTMENT | Many-to-One | Partial both sides |
| HAS_DEPENDENT | PROFESSOR -- DEPENDENT | One-to-Many | Partial (PROFESSOR), Total (DEPENDENT -- weak entity) |
Special Requirements Checklist
| Requirement | Fulfilled By |
|---|---|
| At least 5 entities | STUDENT, COURSE, DEPARTMENT, PROFESSOR, DEPENDENT |
| One weak entity | DEPENDENT (depends on PROFESSOR; identified by DepName + ProfID) |
| Many-to-Many relationship | STUDENT ENROLLS COURSE |
| Derived attribute | Age (derived from DOB) in STUDENT |
| Multi-valued attribute | Phone in STUDENT |
| Total participation | STUDENT 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
| Symbol | Meaning |
|---|---|
[ ] | 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 line | Total participation |
| A single line | Partial participation |
| Underline | Primary key |
| Dashed underline | Partial (discriminator) key of a weak entity |
Cardinality Summary
| Relationship | Participating entities | Cardinality | Remark |
|---|---|---|---|
| BELONGS_TO | STUDENT, DEPARTMENT | M:1 | Total on the STUDENT side, every student belongs to exactly one department |
| ENROLLS | STUDENT, COURSE | M:N | A student takes many courses and a course is taken by many students |
| TEACHES | PROFESSOR, COURSE | 1:N | Each course is taught by one professor, a professor may teach several |
| WORKS_IN | PROFESSOR, DEPARTMENT | M:1 | Each professor is attached to one department |
| HAS_DEPENDENT | PROFESSOR, DEPENDENT | 1:N identifying | DEPENDENT 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.
2079 · 10 marks
Explain the various Symbols used in E-R Model?[10]
Show solved answerHide 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)
10. Lines ( Links )
- 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:
| Notation | Meaning |
|---|---|
| 1 : 1 | One-to-One |
| 1 : N | One-to-Many |
| M : N | Many-to-Many |
- Example: One DEPARTMENT has many EMPLOYEEs (1:N)
Summary Table
| Symbol | Shape | Represents |
|---|---|---|
| Rectangle | Single box | Entity Set |
| Double Rectangle | Double box | Weak Entity Set |
| Ellipse | Single oval | Attribute |
| Double Ellipse | Double oval | Multivalued Attribute |
| Dashed Ellipse | Dotted oval | Derived Attribute |
| Ellipse (underlined) | Oval + underline | Key Attribute |
| Dashed underline | Dotted underline | Partial Key |
| Diamond | Single diamond | Relationship Set |
| Double Diamond | Double diamond | Identifying Relationship |
| Single Line | Thin line | Partial Participation / Link |
| Double Line | Thick/double line | Total 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.
2078 · 5 marks
What is an E-R Diagram? Explain various symbols used in the E-R Diagram.[5]
Extended ER model constraints
2082 · 5 marks
Discuss the various types of constraints used on Extended ER Model. [5]
Attribute types and derived attributes
2080 · 5 marks
What is Attributes? Explain different types of Attributes with example. [5]
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]
Generalization and specialization
0 · 5 marks
What do you mean by generalization specialization in EER? Illustrate with examples. [5]
Make Unit 2 stick
Practice BIT202 with flashcards & quizzes