Topic 3 Case Study
Topic 3 Case Study
Answers:
Case Study 1: University Course Enrollment System
1. Identify and explain the relationships among the three tables. What type of
relationships exist between them?
• The database contains three tables: Students, Courses, and Enrollments.
• The Students table has a one-to-many (1:M) relationship with the Enrollments
table because one student can enroll in multiple courses, but each enrollment
entry corresponds to only one student.
• The Courses table also has a one-to-many (1:M) relationship with the
Enrollments table because one course can have many students enrolled, but
each enrollment entry corresponds to only one course.
• The Enrollments table acts as a bridge table that resolves the many-to-many
(M:N) relationship between students and courses by breaking it into two 1:M
relationships.
2. How is referential integrity enforced in this database? Provide an example of a
violation.
• Referential integrity is enforced using foreign keys:
o Student_ID in Enrollments references Student_ID in Students.
o Course_ID in Enrollments references Course_ID in Courses.
• These foreign key constraints ensure that an enrollment record cannot reference
a non-existent student or course.
Example of a violation:
• If a student with Student_ID = 105 is deleted from the Students table, but their
enrollment records still exist in Enrollments, referential integrity is violated.
• To prevent this, we can enforce ON DELETE CASCADE (deletes related
enrollments automatically) or ON DELETE RESTRICT (prevents student deletion
if enrollments exist).
Answers:
2. How can we retrieve the total sales revenue for each product using relational
algebra?
To calculate total sales revenue for each product, we follow these steps:
Questions
1. Identify and explain the relationships among the three tables. What type of
relationships exist between them?
2. Explain how referential integrity is enforced in this database and provide an example
of a situation where a referential integrity constraint might be violated.
3. Explain the role of the Loans table in handling the many-to-many (M:N) relationship
between students and books. Why is it necessary?
4. The library wants to retrieve the number of times each book has been loaned. Which
relational algebra operations would be used to accomplish this? Describe the steps
involved.
END OF QUESTIONS