2082 2

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]

Database Management SystemChapter 2: Entity-Relationship ModelER diagram purpose and symbols

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:

  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.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.