0% found this document useful (0 votes)
20 views6 pages

Assignment 2

The document outlines the guidelines and requirements for Assignment 02 in a Database course for Spring 2025 at The Superior University Gold Campus, Lahore. It includes instructions for SQL queries related to an adult literacy program and a hotel management system, as well as basic queries and data manipulation tasks for an Employees table. The assignment emphasizes the importance of originality, submission format, and deadlines, with a focus on learning through problem-solving.

Uploaded by

2w5tkpw7hn
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)
20 views6 pages

Assignment 2

The document outlines the guidelines and requirements for Assignment 02 in a Database course for Spring 2025 at The Superior University Gold Campus, Lahore. It includes instructions for SQL queries related to an adult literacy program and a hotel management system, as well as basic queries and data manipulation tasks for an Employees table. The assignment emphasizes the importance of originality, submission format, and deadlines, with a focus on learning through problem-solving.

Uploaded by

2w5tkpw7hn
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/ 6

Assignment 02

Database, Spring 2025


Department of Software Engineering,
Faculty of Computer Science & Information Technology,
The Superior University Gold Campus, Lahore.
Submission Deadline: Friday 11:59 PM, February 21, 2025
__________________________________________________
Question CLO Domian/BT Level Total Marks
1-3 2 C2 60

Advice and Submission Guidelines for Assignment

• Make sure that you read and understand each and every instruction. If you have any
questions or comments you are encouraged to discuss (only) with your colleagues and
instructor.
• Run all the queries on sql server. Take screenshot of query and output.
• Paste screenshots of your work on word file, later you can convert this word file into
PDF file as well. Upload PDF file on the Google classroom and keep code files with
you (better in your own email) as it will be used for evaluation and viva.
• All the submitted evaluation instruments (quizzes, assignments, lab work, exams, and
the project) will be checked for plagiarism.
• Your word/pdf file should be named as your complete roll number e.g. bsse-f22-001.
• Copied assignments will be graded as zero.
• Late Submission will not be accepted.

While assignments are designed to assess your understanding and skills, they are also
opportunities to learn and grow. Enjoy the process of solving problems and building
solutions!

Question 1:
Write SQL queries to create database and tables men5oned in following case study. You
can also refer to the following image.
The database tracks an adult literacy program. Tutors complete a cer7fica7on class offered
by the agency. Students complete an assessment interview that results in a report for the
tutor and a recorded Read score. When matched with a student, a tutor meets with the
student for one to four hours per week. Some students work with the same tutor for years,
some for less than a month. Other students change tutors if their learning style does not
match the tutor’s tutoring style. Many tutors are re7red and are available to tutor only part
of the year. Tutor status is recorded as Ac7ve, Temp Stop, or Dropped.
• Insert the data showed in picture, in tables that you have created.
Write queries to answer the following ques5ons. Display the output.
• How many tutors have a status of Temp Stop? Which tutors are ac7ve?
• List the tutors who took the cer7fica7on class in January.
• How many students were matched with someone in the first five months of the
year?
• Which student has the highest Read score?
• How long had each student studied in the adult literacy program?
• What is the average length of 7me a student stayed (or has stayed) in the program?
Question 2:
Design a database for fictional Hotel Management System. In this scenario, the
system manages information about hotel rooms, guests, reservations, and room
service orders. The Hotel Management System is responsible for managing hotel
operations such as room bookings, guest check-ins, and room service orders. The
hotel offers different types of rooms with varying rates and amenities. Guests can
make reservations online or in person. Create following tables with mentioned
columns.
Rooms: RoomNumber(Primary Key), Type, Rate, Capacity(Not Null), Occupied Bit
(Default=0)
Guests: GuestID (Primary Key), FirstName, LastName, email(unique), Phone(non
negative), PaymentMethod(Not Null)
Reservations: confirmationNumber(Primary Key), GuestID(Foreign key),
RoomNumber(Foreign Key), CheckInDate, CheckOutDate, TotalAmount

Insert following data in above designed tables.


Rooms:
RoomNumber Type Rate Capacity Occupied
Bit
101 Standard 100.00 2 0
102 Deluxe 150.00 2 0
103 Suite 200.00 4 0

Guests:
GuestID FirstName LastName email Phone PaymentMethod
1 Ali Akbar [email protected] 123456789 Credit Card
2 Gohar Zia [email protected] 987654321 Cash
3 Irum Rasool [email protected] 456987123 Credit Card

Reservations:
Confirmation GuestID RoomNumber CheckInDate CheckOutDate TotalAmount
Number
1001 1 101 2024-03-01 '2024-03-05 400.00
1002 2 102 2024-03-03 '2024-03-07 600.00
1003 3 103 2024-03-05 '2024-03-10 1000.00

• Update the record having 102 id in Rooms table. Change the type of room
from ‘Deluxe’ to ‘Standard’.
• Search the customer named as Ali and delete its record. Make sure it also
gets remove from reservation table as well.
• Write a query to calculate the total revenue generated by the hotel for a
specific time period. This involves summing up the total amount from
room reservation.

Question 3: Create the tables mentioned below. For each query, you are required to:
1. Write the SQL query.
2. Execute the query on the provided tables.
3. Provide the output.
Part 1: Basic Queries
1. Retrieve all columns from the Employees table.
2. Retrieve the FirstName, LastName, and Salary of all employees.
3. Retrieve the EmployeeID, FirstName, and LastName of employees whose salary
is greater than 50000.
4. Retrieve the EmployeeID, FirstName, and LastName of employees whose last
name starts with "S".
5. Retrieve the EmployeeID, FirstName, and LastName of employees who were
hired after January 1, 2020.
Part 2: Filtering and Sor5ng
6. Retrieve the FirstName, LastName, and Salary of employees sorted by Salary in
descending order.
7. Retrieve the FirstName, LastName, and HireDate of employees who work in
the department with DepartmentID = 2.
8. Retrieve the FirstName, LastName, and JobTitle of employees whose job title is
either "Manager" or "Developer".
9. Retrieve the FirstName, LastName, and Email of employees whose email
contains "gmail.com".
Part 3: Aggrega5on
10. Retrieve the total number of employees in the Employees table.
11. Retrieve the average salary of all employees.
12. Retrieve the total budget of all projects.
13. Retrieve the number of employees working in each department
(display DepartmentID and the count of employees).
Part 4: Data Manipula5on
14. Insert a new employee into the Employees table with the following details:
• EmployeeID: 101
• FirstName: "Emily"
• LastName: "Davis"
• Email: "[email protected]"
• PhoneNumber: "123-456-7890"
• JobTitle: "Analyst"
• Salary: 60000
• DepartmentID: 3
15. Update the Salary of all employees in the Employees table to increase it by
10%.
16. Delete all employees from the Employees table who were hired before January
1, 2015.
17. Insert a new project into the Projects table with the following details:
• ProjectID: 501
• ProjectName: "New Product Launch"
• StartDate: "2023-11-01"
• EndDate: "2024-05-31"
• Budget: 150000
• DepartmentID: 2
18. Assign employee with EmployeeID = 101 to the project with ProjectID =
501 and set HoursWorked to 50.

You might also like