0% found this document useful (0 votes)
13 views

DBMS demo question

The document contains a comprehensive set of SQL exam questions covering various database operations, including creating tables, inserting data, modifying records, and performing queries on multiple relations. It also includes tasks related to relational schemas, views, joins, and triggers, along with viva questions on database concepts and SQL statements. The questions are structured to test knowledge on practical SQL applications and theoretical database principles.
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)
13 views

DBMS demo question

The document contains a comprehensive set of SQL exam questions covering various database operations, including creating tables, inserting data, modifying records, and performing queries on multiple relations. It also includes tasks related to relational schemas, views, joins, and triggers, along with viva questions on database concepts and SQL statements. The questions are structured to test knowledge on practical SQL applications and theoretical database principles.
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/ 9

Lab exam and viva questions

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

2. Consider the following relational database


Employee(Empno,Name,Address,salary)
The primary key are underlined
Employee
Empno Name Address Salary
1 Ram Kathmandu 50000
2 Sita Lalitpur 60000
3 Gopal Pokhara 55000
4 Sunita Kathmandu 52000
5 Hari Lalitpur 48000

Now write SQL command for the following:

i) Insert data as per given table


ii) Modify the database so that Ram now lives in Pokhara
iii) Find average salary of employee for each address
iv) Find the information of employee whose salary is greater than average salary of all
employees
v) Delete the information of employee whose name is Hari
3. Consider the table tbl_emp as follow

EmpId* EmpName Salary(Nrs.) Date_of_join Phone Department


E001 Ram 20000 2060-02-01 #1234 Packing
E002 Hari 18000 2065-04-01 #5647 Cleaning
E004 Sita 15000 2068-04-01 #2564 Polishing
Write the SQL statements for the following
i) Insert a record as per given table
ii) Change the Department of Hari to marketing
iii) Increase the salary of all employee by 5000
iv) Select the row having salary greater than 16000
v) Add a new column Address to the above table
vi) Delete the record of sita

4. Consider the relational schema:


Teacher (TeacherID,TeacherName,Offfice)
Write SQL statements for the following task:
i. To create a table from a table and insert at least 5 records
ii. To eliminate duplicate rows
iii. To add new column ‘Gender’ in the table
iv. To sort data in a table
v. To delete rows
vi. Count the number of rows based in office

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.

7. Consider the following schemas


Doctor(Name,age,address)
Works(Name,Depart_no,salary)
Department(Depart_no,dept_name,floor,room)

Write down the SQL statement for the following


1. Create the table for above schemas in such a way that referential integrity constraints must
maintained .(underline attributes represent primary key)
2. Insert at least 3 rows for each table
3. Draw schema diagram for above schemas

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

i) create a database named hotel and table relation


ii) Insert the above rows
iii) create a view named price which shows hotel name and its worth
iv) modify the data so that hotel chitwan is now four star level
v) delete the records of all hotels having worth more than 9M
9. Write a SQL statements for the following
Create a table named Automotor with chasis_number as primary key and following
attributes.
veh_brand,veh_name,veh_model,veh_year,veh_cost,veh_color,veh_weight
i. Enter a full detailed information of automotor( at least 5 rows)
ii. Change any Automotor’s year to 2019
iii. Remove all Automotor’s records whose model contains ‘i’ in last position
iv. Display the total cost of all vehicles of the table Automotor
v. Create a view from above table having vehicle only red color
vi. Display details of Automotor ordering on descending manner by brand name and ascending order on
model when brand matches

10. Let us consider the following relation

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

Write a SQL statements for the following

i) Insert the above records


ii) Find the records of sailors who have reserved boat number 103(bid=103)
iii) Update the color of the boat ,where bid is 102,into green
iv) find the name of sailors who have reserved a red or green boat
v) find the name of sailors who have reserved boat number 103 on day 4
vi) find the name of sailors whose name is not ‘Bob’
vii) find the name of all boats
11.Consider the relation Actress_Details and Write SQL statements for the following queries.
Players_id Actress_name Debut_year Recent_release Actress_fee
1 Renu 2010 Samay 400000
2 Sita 2022 Radha 300000
3 Geeta 2001 Mato 600000
4 Amita 1990 Man 700000
5 Karishma 1989 Prem 100000

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

E_id Fname Lname Department Salary Hire_Date


01 Ramu Bashyal Sales 20000 2023-08-08
02 Damu Pandey IT 50000 2022-01-01
03 Biru B.k. Sales 40000 2021-02-10
04 Hiru Dhamala HR 35000 2023-12-18
05 Biren Khadka IT 60000 2012-10-22

i)Create a database named Company and Employees relation.


ii) Insert the above rows
ii)Create a view that shows the E_id ,Department and Hire_Date of all employees
iii)Modify the table such that the Department of Biren is HR now.
iv) Delete the record of employees whose Lname is “Pandey”
13. Consider the following table

order_id product_name price quantity order_date delivery_date


1 T-shirt 25.99 2 2023-07-15 2023-07-25
2 Jeans 49.95 1 2023-07-17 2023-07-20
3 Shoes 69.50 1 2023-07-20 2023-07-30
4 Sunglasses 12.75 3 2023-07-22 2023-07-28
5 Backpack 34.99 2 2023-07-25 2023-07-29

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.

15. Demonstrate the use of DDL statements.

16.Demonstrate the use of TCL statements

17. Create any two table and insert the rows and perform the following join
• Inner join
• Outer join
• Natural join
• Cross join

18. Demonstrate the use of stored procedures

• Without using parameters


• With parameters
19.Demonstrate the use of triggers in SQL.

20.Create the following table and insert the records below

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

Write SQL queries to


i. Find emp_name,position,salary of employee who works in finance department
ii. Find name of employee who works in sales department
iii. Find the average salary of employee
iv. Find the employee with minimum salary
v. Delete information of employee whose salary is less than average salary
vi. Find the HOD of Riya
21. Create two table named emp_civildepartment and emp_computerdepartment with following
columns with appropriate data types and insert the following data in table
After insertion your table must look like as follows:
emp_civildepartment
emp_id emp_name address
1 Kapil Chitwan
2 Ujwal Dharan
3 Pradip Palpa
4 Prakash Kathmandu
5 Supriya Mahendranagar

emp_computerdepartment

emp_id emp_name address


1 Mukunda Surkhet
2 Santosh Pokhara
3 Pradip Palpa
4 Jasbin Kathmandu
5 Supriya Mahendranagar

perform the following set operations


i. UNION
ii. UNION ALL
iii. INTERSET
iv. EXCEPT

Write SQL queries for the following:


i. Find the name of employee who works either civil or computer department
ii. Find the name of employee who works in both civil and computer department
iii. Find the name of employee who works in computer department but not in civil department
iv. Find the common address of where both computer and civil department employee lives in .
Viva Questions
Viva questions will be related from following topics

• DDL, DML, DCL and TCL statements


• Database application architecture
• Data abstraction, physical and logical data independence
• ER diagram (Entity (strong and weak entity
)set,attributes,relationship,generalization,specialization,aggregations, types of keys, role in ER
diagram, cardinality constraints)
• Schemas and instances, Schema diagram
• Relational model, Relational DBMS ,Advantages
• SQL constraints(primary key, foreign key, default, check, unique, not null)
• Operators in SQL, data types, specially focused on(LIKE, AS,BETWEEN,AND,OR, IN,NOT IN,
wildcard characters, order by)
• Join operations, set operations, subquery
• stored procedure, views, role of views in security, authentication vs authorization, Triggers,
Assertions
• Group by and having clause, where clause, aggregate functions, Difference between having and
where clause
• Normalization, functional dependencies
• Steps of query processing, query optimization, query cost estimation
• Log and log records, deferred and immediate database modification
• ACID properties of transaction, serial and non-serial schedule, serializability, conflict and view
serializability, lock based protocols

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy