BS-SE / BS-CS Program CS-244 GIFT University Gujranwala
Course: Database Systems (Lab) (Spring 2024)
Resource Person: Hina Jamil
LAB ASSIGNMENT-02
Name:
Roll No:
Total Points: 20
Instructions: Please Read Carefully!
• This is an individual assignment. Everyone is expected to complete the given
assignment on their own, without seeking any help from any website or any other
individual. There will be strict penalties for any work found copied from any source
and the university policy on plagiarism will be strictly enforced.
• There will be a Lab test assessment(s) based on this assignment.
Assignment Submission Method:
• You are expected to submit this assignment as:
a. Turn the Same Word document with solution on your Google Classroom.
• Assignment is to be submitted via Google Classroom within the stated deadline above.
a. Rename the document with your Name_Reg#.
• Any assignment submission not following the above directions will not be accepted!
• Late submissions carry a 50% penalty!
Page 1 of 3
BS-SE / BS-CS Program CS-244 GIFT University Gujranwala
DDL /DML: (2+3+2+1+2)points
Q1) Write a SQL statement to create a table named Room including columns room_no,
room_category, location, room_price (6 digits) and make sure that the room_no column will
be a key field which will not allow any duplicate data at the time of insertion.
Q2) Write a SQL statement to create a table named Person including columns person_id,
first_name, last_name, person_mobile, person_email, person_address and room_id. Make sure
that the person_id column must be a key field which will not allow any duplicate data at the
time of insertion. The foreign key column room_id contains only those values which are
existing in the room table. Your foreign key constraint name must be fk_room_id which is
referencing to the room_no in the room table. Your foreign key must not allow any deletion
and updation at the parent table.
Hint: Use any of the concepts restrict, set null or cascade (according to requirement).
Q3) Insert at least 4-5 rows in each table.
Q4) Rename table Person as Person_details.
Q5) Alter table Orders and add a new column of the name “Order_Amount”. Ensure it is 10
digits, check that value should be greater than zero and it doesnot allow empty entries.
Submission:
You are required to submit your .sql file (named as YourName) that contains all your queries
(creation as well as insertion). Make sure your file should be importable and free from errors.
Also, submit text files of your creation and insertion queries. Name of text files are as follows:
creation_yourname_reg#.text and insertion_yourname_reg#.text
Page 2 of 3
BS-SE / BS-CS Program CS-244 GIFT University Gujranwala
Instructions:
1. Create database on phpMyAdmin with the name “Library”.
2. Import file “lms_database.sql” and here you go all the tables and data will be
imported.
3. Read the queries carefully, perform the query on phpMyAdmin and screenshot
the result.
4. Copy and paste the queries and add screenshot of the result for all the queries.
5. Note: Cropped Image will not be accepted. You are required to take entire screen
snapshot
Write SELECT statement for the following. (2*5=10 Points)
1. Write an sql statemtent to display book_code, book_title, author, publication and
publish date of all those Books whose Publication is “Prentice Hall”. Change column
headings as Book_ID, Title, Author, Publisher and Publish_date.
2. Write an sql statement to display book_code, book_title, publication and
publish_date of all those books where publish_date is after “2010-12-11”. Change
column headings as Book_ID, Title, Publisher and Date. Display column should be in
ascending order of book_title.
3. Write an SQL statement displaying Member_ID, Member_name, date_expire and
membership_status of those members where expiry date is after “2013-04-21” and
membership_status is “Temporary”.
4. Write an SQL statement displaying fine_range and fine_amount where fine_amount
is greater than 75. Change column headings as Fine_ID and Amount. Fine amount
should be be displayed from highest to lowest amount.
5. Write an SQL statement displaying supplier_id, supplier_name, address, email
where emails end at “aol.com” and starts with “a”. Change column headings as
Sup_ID, Supp_Name, Address, Email. Sort in descending order of address.
**END OF ASSIGNMENT**
Page 3 of 3