DBMS Lab Final Exam
DBMS Lab Final Exam
For Example, for each task these follow the following format:
Question 1 - Task 1
Your query
Output Screenshot
6. Once you have completed all the task, make a pdf of your solution file.
7. Copy all your submission files (.docx, ,pdf, and .sql) in a folder. The name of that
folder should be like RollNumber-Name-Section.
(For example: 222-BSCS-18-Ahmad-E1)
8. Compress the above folder in (.zip, .tar, or .rar) format with the same name and submit
on the submission link that has been shared with you.
9. Late submission will be marked/graded ZERO.
10. Do not copy anything from others. Your document, output screenshot must be unique.
Plagiarized content will also be marked as ZERO.
BEST OF LUCK!
Question 1 (10 Marks)
Requirements:
Tasks:
1. Write Queries to create above tables in Database. (Important Note: Name of the database must be
your roll number in which you will create the tables) (2 marks)
2. List the attributes from the above tables which should be marked as primary keys? (1 marks)
3. Write query to Alter the above tables and add primary constraints to the attribute that you justified in
above question. Copy and Paste script for adding constraint of primary key in all tables here:(2 marks)
4. Identify the attributes in each table that can be classified as a foreign key (2 marks)
5. Write Query to update above tables to add foreign key constraint to the attributes that you specified in
above question. Execute query in your database (2 marks)
6. Generate script of the above database. Save it with the same name as database name. And send it
along with the solution that you will submit. (1 mark)
Question 2 (20 Marks)
1. Display all the details of employees who ended job at 19 Dec-07. (2 marks)
2. Select all fields from "LOCATIONS" where country ID is "UK" AND city must be "OXFORD" OR
"MUNICH" (use parenthesis to form complex expressions) (2 marks)
3. Write a query in SQL to display all those employees whose first name starts with letter P and ends with
letter k or the seventh digit in their phone number equals 3 and make the result set in a descending order
by the first name. (2 marks)
4. Write a query in SQL to display the full name (first and last name), department name, job title and city
of employee whose ID is 100. (2 marks)
5. Write a query in SQL to display the full name (first and last) and salary for those employees who earn
less than the employees whose Id is 182. (3 marks)
6. Display the country name and number of cities in each country. (3 marks)
7. Display the first name, salary, email and department name of employees working in ‘Tokyo’ city. (3
marks)
8. Write script for following: (3 marks)
a. Fetch the substring Relational from string 'Oracle Database is an Relational Database ' (1)
b. Display the first name of employees in upper case, lower case and initcap case (1)
c. Fetch the position of sub string RDBMS 'Oracle Database is an RDBMS ' (1)
OR
Write a query to create a VIEW that will display the employee name, salary, department name, city,
country, and region name using Joins.