Lab 3
Lab 3
1. Introduction
This lab introduces the fundamentals of the Entity-Relationship (ER) Model, a crucial step in
database design. Students will explore the symbols used in ER diagrams, understand their
significance, and apply them through a comprehensive example of a University Management
System. The manual covers every aspect of ER modeling, including identifying entities,
attributes, relationships, cardinality, participation constraints, weak entities, and multivalued
attributes. It concludes with SQL implementations, corresponding table structures, a full
system-level ER diagram, and a symbols reference sheet. The goal is to ensure students gain both
theoretical and practical expertise.
2. Learning Outcomes
3. Lab Setup
● Software Requirements:
o Online Tools: Lucidchart, draw.io, Creately
o Offline Tools: Microsoft Visio or graph paper for manual sketches
o Database Management System: MySQL Workbench or PostgreSQL with
pgAdmin
Page 1 of 11
Database Systems LAB SPRINIG 2025
Page 2 of 11
Database Systems LAB SPRINIG 2025
4. Multivalued Attribute (Double Oval): For attributes with multiple values (e.g., Phone
Numbers).
5. Derived Attribute (Dashed Oval): Computed attributes (e.g., Age from Date of Birth).
6. Relationship (Diamond): Shows associations (e.g., Enrolls connects Student and
Course).
7. Identifying Relationship (Double Diamond): Connects a weak entity to its owner.
8. Line (Straight Line): Links attributes and entities; dashed lines denote derived
attributes.
9. Cardinality Indicators (Crow’s Foot): Indicate multiplicities like 1:1, 1:N, M:N.
10.Generalization/Specialization (Triangle): Demonstrates entity hierarchies.
This section provides a step-by-step example covering the entire ER modeling process, including
a full system-level diagram, SQL implementations, and corresponding table structures.
"A university tracks students, courses, instructors, and departments. Students enroll in courses,
and each course is taught by an instructor. Departments offer courses, and students belong to
departments. Courses may have projects. The system keeps enrollment records, instructor
assignments, and departmental offerings."
Entity Attributes
Student student_id (PK), name, email, date_of_birth
Course course_code (PK), title, credits
Instructor instructor_id (PK), name, email
Department dept_id (PK), name, location
Enrollment enrollment_id (PK), date_enrolled, grade
Project (Weak Entity) project_id (Partial Key), project_title
Note: "Enrollment" acts as a relationship entity capturing attributes like date_enrolled and
grade.
Page 4 of 11
Database Systems LAB SPRINIG 2025
Below is the full ER diagram, showcasing all entities, attributes, relationships, cardinalities, and
symbols.
Page 5 of 11
Database Systems LAB SPRINIG 2025
5.5 Step 4: Translating ER Diagram to Relational Schema with SQL and Table Structures
Below are the SQL commands with corresponding table representations to help students
visualize the created tables.
Page 6 of 11
Database Systems LAB SPRINIG 2025
Page 7 of 11
Database Systems LAB SPRINIG 2025
INSERT INTO Department VALUES (1, 'Computer Science', 'Building A'), (2,
'Mathematics', 'Building B');
INSERT INTO Instructor VALUES (101, 'Dr. Alice', '[email protected]'), (102, 'Dr.
Bob', '[email protected]');
INSERT INTO Course VALUES ('CSE101', 'Programming I', 3, 1), ('MTH201',
'Calculus', 4, 2);
INSERT INTO Student VALUES (1001, 'John Doe', '[email protected]', '2000-05-12', 1),
(1002, 'Jane Smith', '[email protected]', '1999-07-23', 2);
INSERT INTO Enrollment VALUES (1, 1001, 'CSE101', '2024-01-15', 'A'), (2, 1002,
'MTH201', '2024-01-17', 'B');
INSERT INTO Project VALUES (501, 'CSE101', 'Chatbot Development'), (502,
'MTH201', 'Statistics Report');
Department Table:
Page 8 of 11
Database Systems LAB SPRINIG 2025
Instructor Table:
Course Table:
Student Table:
Enrollment Table:
Output:
name date_enrolled
John Doe 2024-01-15
-- Find instructors teaching more than one course
SELECT i.name, COUNT(*) AS course_count
FROM Instructor i JOIN Course c ON i.instructor_id = c.dept_id
GROUP BY i.name HAVING course_count > 1;
Page 9 of 11
Database Systems LAB SPRINIG 2025
Output:
name course_count
(No results) (In this sample data, no instructor teaches more than one course)
Note: To see meaningful results, assign more courses to the same instructor in the data.
Deliverables:
Students must:
Use the cheatsheet while designing to avoid confusion. Ensure proper use of primary and foreign
keys, and validate relationships through sample data queries. Always review the resulting tables
to understand how the ER model translates into a functional database.
Page 10 of 11
Database Systems LAB SPRINIG 2025
Page 11 of 11