0% found this document useful (0 votes)
22 views4 pages

Topic 3 Case Study

The document presents case studies on database systems for a university course enrollment system and an online retail store, detailing the relationships among tables and the enforcement of referential integrity. It explains the one-to-many relationships between students and enrollments, as well as the necessity of a bridge table for handling many-to-many relationships. Additionally, it outlines the steps for retrieving total sales revenue for products and discusses a library management system's structure and operations.

Uploaded by

farrafarisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Topic 3 Case Study

The document presents case studies on database systems for a university course enrollment system and an online retail store, detailing the relationships among tables and the enforcement of referential integrity. It explains the one-to-many relationships between students and enrollments, as well as the necessity of a bridge table for handling many-to-many relationships. Additionally, it outlines the steps for retrieving total sales revenue for products and discusses a library management system's structure and operations.

Uploaded by

farrafarisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Topic 3: Case Study Tutorial

Case Study 1: University Course Enrollment System


A university is developing a database system to manage course enrollments. The
database consists of three main tables: Students, Courses, and Enrollments.
• The Students table contains Student_ID (Primary Key), Name, Email, and
Program.
• The Courses table contains Course_ID (Primary Key), Course_Name, Credits,
and Department.
• The Enrollments table contains Enrollment_ID (Primary Key), Student_ID
(Foreign Key referencing Students), Course_ID (Foreign Key referencing Courses),
and Enrollment_Date.
Questions:
1. Identify and explain the relationships among the three tables. What type of
relationships exist between them?
2. Discuss how referential integrity is enforced in this database and provide an
example of a situation where a referential integrity constraint might be violated.

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).

Case Study 2: Online Retail Store Database


An online retail store maintains a sales database to track customer orders. The
database consists of four tables: Customers, Orders, Products, and Order_Details.
• The Customers table stores Customer_ID (Primary Key), Name, Email, and
Phone_Number.
• The Orders table stores Order_ID (Primary Key), Customer_ID (Foreign Key
referencing Customers), Order_Date, and Total_Amount.
• The Products table stores Product_ID (Primary Key), Product_Name, Category,
and Price.
• The Order_Details table stores OrderDetail_ID (Primary Key), Order_ID (Foreign
Key referencing Orders), Product_ID (Foreign Key referencing Products),
Quantity, and Subtotal.
Questions:
1. Explain the role of the Order_Details table in handling the many-to-many (M:N)
relationship between orders and products. Why is it necessary?
2. The store wants to retrieve the total sales revenue for each product. Which
relational algebra operations would be used to accomplish this? Describe the
steps involved.

Answers:

Case Study 2: Online Retail Store Database


1. Explain the role of the Order_Details table in handling the many-to-many (M:N)
relationship between orders and products. Why is it necessary?

• In a retail store database:


o A single order can include multiple products.
o A single product can be part of multiple orders.
o This creates an M:N relationship between Orders and Products, which
cannot be directly implemented in relational databases.
• The Order_Details table resolves this M:N relationship by:
o Storing Order_ID (Foreign Key referencing Orders).
o Storing Product_ID (Foreign Key referencing Products).
o Including additional attributes like Quantity and Subtotal.
• Without Order_Details, there would be data redundancy and difficulty in
tracking quantities of products in each order.

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:

1. JOIN Order_Details and Products:


o PRODUCT_SALES ← Order_Details ⨝ Products
o This links each order detail with the product price.
2. Calculate Total Revenue for Each Product:
o Multiply Quantity * Price to get Total_Revenue for each row.
o PROJECT (Product_ID, Product_Name, (Quantity * Price) AS Revenue)
(PRODUCT_SALES)
3. SUM Revenue for Each Product:
o TOTAL_REVENUE ← SUM Revenue GROUP BY Product_ID
o This aggregates total sales per product.
4. Return the results:
o PROJECT (Product_ID, Product_Name, TOTAL_REVENUE)
Based on the above case studies, answer the following questions:
Case Study: Library Management System
A university library is implementing a relational database to manage book loans. The
database consists of the following tables:
Students: Student_ID (Primary Key), Name, Email, Program.
Books: Book_ID (Primary Key), Title, Author, Category, Availability_Status.
Loans: Loan_ID (Primary Key), Student_ID (Foreign Key referencing Students), Book_ID
(Foreign Key referencing Books), Loan_Date, Return_Date.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy