0 Casestudy
0 Casestudy
CASE STUDY
Entities:
Customer
Product
Order
OrderItem
Payment
Address
Relationships:
Customer places multiple Orders.
Each Order contains multiple OrderItems. PO1,PO2,
Orders have Payments associated.
PO3,PO4,
Customers have multiple Addresses.
PO5,PO6,
Schema Diagram: L4 CO6 PO7,PO8,P 25
Customer (CustomerID [PK], FirstName, LastName, O9, PO11,
Email) PO12,
Order (OrderID [PK], CustomerID [FK], OrderDate) PSO1,PSO
OrderItem (OrderItemID [PK], OrderID [FK], 2
ProductID [FK], Quantity)
Product (ProductID [PK], ProductName, Price)
Payment (PaymentID [PK], OrderID [FK],
PaymentDate, Amount)
Address (AddressID [PK], CustomerID [FK], Street,
City, State, ZipCode)
1. Retrieve the total number of orders placed by
each customer along with their full name. Sort
the result in descending order of the number of
orders.
2. Find the total revenue generated from orders
placed on a specific date. Include the date,
total revenue, and the number of orders placed
on that date.
3. Retrieve the top 5 best-selling products (in
terms of quantity) along with their total sales
revenue.
4. List all customers who have not placed any
orders yet.
5. Calculate the average order amount (total
payment amount) for orders placed by
customers who have more than one address.
Entities:
Patient
Doctor
Appointment
Treatment
Room
Nurse
Relationships:
Patients have Appointments with Doctors.
Doctors treat multiple Patients.
Appointments are held in Rooms.
PO1,PO2,
Nurses assist in Treatments.
PO3,PO4,
Schema Diagram: PO5,PO6,
Patient (PatientID [PK], FirstName, LastName, L4 CO6 25
DOB) PO7,PO8,P
O9, PO11,
Doctor (DoctorID [PK], FirstName, LastName,
PO12,
Specialization) PSO1,PSO
Appointment (AppointmentID [PK], PatientID 2
[FK], DoctorID [FK], RoomID [FK],
AppointmentDate)
Treatment (TreatmentID [PK], PatientID [FK],
DoctorID [FK], NurseID [FK], TreatmentDate,
Description)
Room (RoomID [PK], RoomNumber,
RoomType)
Nurse (NurseID [PK], FirstName, LastName)
1. List all doctors along with the total number of
patients they have treated, ordered by the
number of patients treated in descending
order.
2. Find the room numbers and types that have
hosted appointments for all weekdays
(Monday to Friday). Include rooms that have
had no appointments as well, showing them
with a count of 0.
3. Calculate the average number of appointments
per patient. Exclude patients who haven't had
any appointments.
4. Retrieve the top 3 most common treatment
descriptions along with the number of times
each description has been recorded.
5. Find all nurses who have assisted in treatments
for patients under the age of 18, along with the
number of such treatments they have assisted
with.
Entities:
Student
Teacher
Course
Enrollment
Grade
Department
Relationships:
Students enroll in Courses. PO1,PO2,
Teachers teach multiple Courses.
PO3,PO4,
Courses belong to Departments.
Grades are assigned to Enrollments. PO5,PO6,
L4 CO6 PO7,PO8,P 25
Schema Diagram: O9, PO11,
Student (StudentID [PK], FirstName, LastName, PO12,
DOB, DepartmentID [FK]) PSO1,PSO
Teacher (TeacherID [PK], FirstName, LastName, 2
DepartmentID [FK])
Course (CourseID [PK], CourseName, Credits,
DepartmentID [FK])
Enrollment (EnrollmentID [PK], StudentID [FK],
CourseID [FK], EnrollmentDate)
Grade (GradeID [PK], EnrollmentID [FK], Grade,
GradeDate)
Department (DepartmentID [PK],
DepartmentName, HeadOfDepartment [FK])
1. Find the students who have enrolled in all
courses offered by their department.
2. Retrieve the courses that have not been
assigned to any teacher yet.
3. Calculate the average grade for each
course. Include courses with no grades
assigned yet, showing their average grade
as NULL.
4. List all departments along with the names
of teachers who are not currently the heads
of any department.
5. Identify the students who have the highest
average grade across all courses they are
enrolled in.
Entities:
Guest
Room
Booking
Payment
Service
Employee
Relationships:
Guests make Bookings for Rooms. PO1,PO2,
Rooms have multiple Bookings.
Payments are associated with Bookings. PO3,PO4,
Employees provide Services. PO5,PO6,
L4 CO6 PO7,PO8,P 25
Schema Diagram:
Guest (GuestID [PK], FirstName, LastName, Email) O9, PO11,
Room (RoomID [PK], RoomNumber, RoomType) PO12,
Booking (BookingID [PK], GuestID [FK], RoomID PSO1,PSO
[FK], CheckInDate, CheckOutDate) 2
Payment (PaymentID [PK], BookingID [FK],
PaymentDate, Amount)
Service (ServiceID [PK], EmployeeID [FK], RoomID
[FK], ServiceDate, Description)
Employee (EmployeeID [PK], FirstName, LastName,
Position)
1. Retrieve all rooms that have never been
booked.
2. Calculate the total revenue generated from
room bookings in the last month, broken down
by room type.
3. Find the employee who has provided the most
services, along with the total number of
services provided.
4. List all guests who have made multiple
bookings, along with the total number of
bookings they have made.
5. Retrieve the top 3 most common service
descriptions provided by employees.
Entities:
- Customer
- Car
- Rental
- Payment
- Location
- Insurance
Relationships:
- Customers rent Cars.
- Cars have multiple Rentals.
- Payments are made for Rentals.
- Insurance covers Rentals.
PO1,PO2,
Schema Diagram: PO3,PO4,
Customer (CustomerID [PK], FirstName, LastName,
Email) PO5,PO6,
Car (CarID [PK], Make, Model, Year) L4 CO6 PO7,PO8,P 25
Rental (RentalID [PK], CustomerID [FK], CarID O9, PO11,
[FK], RentalStartDate, RentalEndDate) PO12,
Payment (PaymentID [PK], RentalID [FK], PSO1,PSO
PaymentDate, Amount) 2
Location (LocationID [PK], RentalID [FK], Address,
City, State, ZipCode)
Insurance (InsuranceID [PK], RentalID [FK],
PolicyNumber, CoverageDetails)
1. Find the total revenue generated from rentals
in each city, ordered by revenue in descending
order. Include cities where no revenue has
been generated with a revenue of 0.
2. Retrieve the top 5 most rented car models,
along with the number of times each model
has been rented.
3. Calculate the average rental duration (in days)
for each car make and model. Exclude cars
that have never been rented.
4. List all customers who have rented cars in two
different states.
5. Find the total insurance coverage amount
provided by each insurance policy, ordered by
coverage amount in descending order. Include
policies that have no coverage amount
specified.
Entities:
Student
Instructor
Course
Enrollment
Assignment
Forum
Relationships:
Students enroll in Courses.
Instructors teach Courses.
Courses have multiple Enrollments.
Assignments and Forum discussions are part of
Courses.
PO1,PO2,
Schema Diagram: PO3,PO4,
Student (StudentID [PK], FirstName, LastName,
Email) PO5,PO6,
Instructor (InstructorID [PK], FirstName, LastName, L4 CO6 PO7,PO8,P 25
Email) O9, PO11,
Course (CourseID [PK], CourseName, InstructorID PO12,
[FK]) PSO1,PSO
Enrollment (EnrollmentID [PK], StudentID [FK], 2
CourseID [FK], EnrollmentDate)
Assignment (AssignmentID [PK], CourseID [FK],
AssignmentName, DueDate)
Forum (ForumID [PK], CourseID [FK], Topic,
PostDate, Content)
1. Find courses that have no enrolled students
yet.
2. Calculate the average number of assignments
per course. Exclude courses that have no
assignments.
3. List all instructors who have taught courses in
more than one department.
4. Retrieve the top 3 most active forums (based
on the number of posts) along with the course
they belong to.
5. Find the student who has enrolled in the most
number of courses.
Entities:
Customer
Trip
Flight
Hotel
Booking
Payment
Relationships:
Customers book Trips.
Trips include Flights and Hotels.
Bookings are made for Flights and Hotels.
Payments are associated with Bookings.
Schema Diagram:
Customer (CustomerID [PK], FirstName, LastName, PO1,PO2,
Email)
Trip (TripID [PK], CustomerID [FK], TripStartDate, PO3,PO4,
TripEndDate) PO5,PO6,
Flight (FlightID [PK], TripID [FK], FlightNumber, L4 CO6 25
DepartureDate, ArrivalDate, DepartureAirport, PO7,PO8,P
ArrivalAirport) O9, PO11,
Hotel (HotelID [PK], TripID [FK], HotelName, PO12,
CheckInDate, CheckOutDate, RoomType) PSO1,PSO
Booking (BookingID [PK], TripID [FK], FlightID 2
[FK], HotelID [FK], BookingDate)
Payment (PaymentID [PK], BookingID [FK],
PaymentDate, Amount)
1. Retrieve all trips along with the total number
of flights and hotels booked for each trip.
2. Find the total amount paid by each customer
for their trips, including flights and hotels.
3. Identify trips where the total payment amount
exceeds a specified threshold (e.g., $1000).
4. List all customers who have booked both a
flight and a hotel for at least one trip.
5. Calculate the average duration of hotel stays
(in days) for each hotel. Exclude hotels that
have never been booked.
Relationships:
- Customers have Accounts.
- Accounts have Transactions.
- Loans are provided to Customers.
- Employees work in Branches.
Schema Diagram:
```plaintext
Account (AccountID [PK], CustomerID [FK],
AccountType, Balance)
Customer (CustomerID [PK], FirstName, LastName,
Email)
Transaction (TransactionID [PK], AccountID [FK],
TransactionDate, Amount, Type)
Loan (LoanID [PK], CustomerID [FK], LoanAmount,
LoanDate, RepaymentDate)
Branch (BranchID [PK], BranchName, Location)
Employee (EmployeeID [PK], BranchID [FK],
FirstName, LastName, Position)
1. Calculate the total balance for each account
type across all accounts.
2. Find customers who have taken loans and
their total outstanding loan amount.
3. List all transactions where the transaction
amount exceeds $10,000.
4. Retrieve the average balance of accounts in
each branch.
5. Find the employee with the highest total
transaction amount processed.
Schema Diagram:
User (UserID [PK], FirstName, LastName, Email)
Post (PostID [PK], UserID [FK], PostDate, Content)
Comment (CommentID [PK], PostID [FK], UserID
[FK], CommentDate, Content)
Like (LikeID [PK], PostID [FK], UserID [FK],
LikeDate)
Group (GroupID [PK], GroupName)
Message (MessageID [PK], SenderID [FK],
ReceiverID [FK], MessageDate, Content)
1. Find users who have liked their own posts.
2. Calculate the total number of comments on
each post, ordered by the number of comments
in descending order.
3. Retrieve posts with the highest number of likes,
along with the number of likes for each post.
4. List all users who have not posted anything yet.
5. Find the most active group in terms of the
number of messages sent within the group.
Entities:
Product
Supplier
Warehouse
InventoryItem
Order
Shipment
PO1,PO2,
Relationships:
PO3,PO4,
Products are supplied by Suppliers.
Products are stored in Warehouses. PO5,PO6,
Inventory Items track Product quantities in L4 CO6 25
PO7,PO8,P
Warehouses.
O9, PO11,
Orders and Shipments track Product movements.
PO12,
PSO1,PSO
Schema Diagram: 2
Product (ProductID [PK], ProductName, Description,
Price)
Supplier (SupplierID [PK], SupplierName,
ContactName, ContactEmail)
Warehouse (WarehouseID [PK], WarehouseName,
Location)
InventoryItem (InventoryItemID [PK], ProductID
[FK], WarehouseID [FK], Quantity)
Order (OrderID [PK], SupplierID [FK], OrderDate,
TotalAmount)
Shipment (ShipmentID [PK], OrderID [FK],
ShipmentDate, WarehouseID [FK])
```
1. Retrieve all products along with their total
quantity across all warehouses.
2. Find suppliers who have not received any
orders yet.
3. Calculate the total amount spent on each
product by summing up the amounts from all
orders containing that product.
4. List warehouses that have received shipments
for all products in their inventory.
5. Find the product with the highest total quantity
across all warehouses.