BIT202 ยท 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 en
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]
Quick answer
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; Communication Tool; Blueprint for Database Design.
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.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.