DBMS demo question
DBMS demo question
1. Write SQL statements for the following queries in reference to relation Emp_time
provided.
Eid# Name Start_time End_time
E101 Magale 10:30 18:30
E102 Malati 8:30 14:30
E103 Fulmaya 9:00 17:00
i. create the table Eid# as primary key and insert the values provided
ii. Select all employees and their total working hours
iii. Find the Employee information as per their least working hours.
iv. Select the employee name who works long hours among all the employees
v. Display the name of the employee whose name start from letter ‘M’ and who work more than seven
hours
5. Write the SQL statements for the following Queries by reference to Liquors_info relation:
Serial_No Liquors Start_year Bottles Ready_Year
1 Gorkha 1997 10 1998
2 Divine Wine 1998 5 2000
3 Old Durbar 1997 12 2001
4 Khukhuri Rum 1991 10 1992
5 Xing 1994 5 1995
i) creates the Liquors_info relation and insert the above records
ii)insert the records in Liquor_info as above
iii)List all the records which were ready by 2000
iv)Remove all records from database that required more than 2 years to get ready
v)Create any views for above relation
6. Write SQL statements for the following:
create a table named Vehicle with veh_number as primary key and following attributes:
veh_brand,veh_year,veh_mileage,veh_price
i. Enter a full detailed information of a vehicle (at least 5)
ii. Increment a vehicle price by 10,000
iii. Display the total price of all vehicles
iv. create a view a from above table
v. Display details of vehicles ordering on descending manner in brand and by mileage when brand
matches
vi. Remove all vehicle’s records whose brand contains character ‘o’ second position
vii. change data type of year to datetime.
8. Write the SQL statements for the following queries by reference of Hotel_details
relation.
Hotel_id Hotel_name Estb_year Hotel_star Hotel_worth
1 Hyatt 2047 Five 15M
2 Hotel ktm 2043 Three 5M
3 Fullbari 2058 Five 20M
4 Yak and Yeti 2052 Four 11M
5 Hotel chitwan 2055 Three 7M
Sailors (sid,sname,rating,age)
Boats(bid, bname,color)
Reserves(sid,bid,day)
Sailors
sid sname rating age
1 John 8 25
2 Alice 7 28
3 Bob 6 22
Boats
bid bname color
101 Speedy Red
102 Swift yellow
103 Sailor Blue
Reserves
sid bid day
1 101 5
2 102 6
3 103 4
i. Create the table Actress_details relation and insert the above rows
ii. Delete the data of actress whose recent release is prem
iii. Modify the database so that Renu’s new release is “Win the race” film
iv. Find the actress with the highest fee
v. Find the name of actress whose name ends with a
vi. Create any views for above relation
12. Write SQL statements for the following queries using the given Employees relation
i. Create table orders by considering order_id as primary key insert the above records (Note
that insert at least one records with today date)
ii. Retrieve all orders placed on a 2023-07-15
iii. Find the number of days that required to delivered shoes
iv. Find all the orders that is received from '2023-07-17' to '2023-07-22'
v. find all the orders that is received today
vi. Calculate the average number of days it takes to deliver a orders
vii. Find the product with highest quantity
14. Create relational database for the Department of computer Engineering (DOCE) of pokhara
university. Your database should have at least three relations and referential integrity constraint
must me maintained and draw schema diagram also.
17. Create any two table and insert the rows and perform the following join
• Inner join
• Outer join
• Natural join
• Cross join
Employee
emp_id emp_name Position salary dept_id
1 Anish Manger 25000 1
2 Sita Secretary 25000 2
3 Ronit Analyst 40000 5
4 Riya Manager 50000 3
Department
dept_id dept_name HOD
1 Sales Janak
2 Marketing Madhav
3 Finance Sapana
4 Operations Durga
emp_computerdepartment