DBMS Questions 2023-24
DBMS Questions 2023-24
Q.1
(a) Write difference between WHERE and HAVING clause.
(c) Write SQL queries for (i) to (iv) and write output for SQL queries (v) to (viii), which
are based on the tables.
Table : EMPLOYEE
ENO NAME DOJ DOB GENDER DCODE
1001 Kshitij 2013-09-02 1991-09-01 Male D01
1002 Kirti Dubey 2012-12-11 1990-12-15 Female D03
1003 Deepak 2013-02-03 1987-09-04 Male D05
1007 Anil Jha 2014-01-17 1984-10-19 Male D04
1004 Jatinder 2012-12-09 1986-11-14 Female D01
1005 Somesh 2013-11-18 1987-03-31 Male D02
1006 Jaya Priya 2014-06-09 1985-06-23 Female D05
Table : DEPT
DCODE DEPARTMENT LOCATION
D01 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order
of ENo.
(ii) To display the name of all the male employees from the table EMPLOYEE.
(iii) To display the Eno and Name of those employees from the table EMPLOYEE
who have born between ‘1987-01-01’ and ‘1991-12-01’
(iv) To count and display FEMALE employees who have joined after ‘1986-01-01’.
Page 1 of 12
(v) SELECT COUNT(*), DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>1;
Q.2
(a) Define degree and cardinality of a relation in RDBMS.
(b) Write the type of SQL command (DDL, DML) from the following:
DROP, DELETE, RENAME, UPDATE
(c) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which
are based on the tables.
Table : EMPLOYEE
ECODE NAME Gender DESIGNATION PLEVEL DOB
785 Sonali F Supervisor P09 1989-10-19
568 Amrita F Operator P06 1994-06-07
256 Ankit M Mechanic P07 1991-11-27
123 Sayani F Clerk P06 1998-07-20
981 Gaurav M Mechanic P07 1995-02-03
Table : PAYMENT
PLEVEL PAY ALLOWANCE
P06 29000 3500
P07 32000 4500
P09 40000 6000
(i) Display the NAME and DESIGNATION of those female Employees whose pay
level is P06.
(ii) Display name of employees whose name has letter ‘a’ as the second
character.
Page 2 of 12
(iii) To display the name of those employees whose age is between 01-01-1992
and 31-12-1996.
(iv) Display name of all employees in alphabetic order.
Q.3
(a) Write difference between CHAR and VARCHAR in MySQL.
(b) Observe the following tables carefully and write the name of most appropriate
attribute which can be considered as foreign key in Employee table.
(c) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which
are based on the tables.
Table: CUSTOMER
CUST_ID CNAME GENDER CTYPE CITY
C01 Hemlata F Prime Jaipur
C05 Saurav M Regular Nagpur
C06 Amar Rai M Prime Surat
C25 Shivani F Regular Guwahati
C41 Devendra M Regular Jaipur
C39 Harshali F Regular Vadodara
Table: ORDER
ORDER_ID PRODUCT QTY AMOUNT ORDERDATE CUST_ID
2856 TV 1 32000 2020-10-07 C05
4213 Mobile 2 26000 2020-11-28 C25
1220 Fan 3 6000 2019-01-05 C39
7895 Refrigerator 1 30000 2022-01-29 C05
6542 TV 2 70000 2021-04-04 C25
Page 3 of 12
Write SQL query for (i) to (iv)
(i) To show orde ID, Product name and quantity of those orders which have the
quantity more than 1.
(ii) To show Product name, Amount and Customer name of those customers who
lives in Nagpur city.
(iii) To Display each type of customer and their numbers from customer table.
(iv) To show the details of all orders in descending order of their order date.
Table : BOOK
Book_Id BookName Author Publisher Price Genre Qty
9788 Geetanjali R. N. Thakur Rajkamal 199 Poetry 5
9789 Godan Premchand Maple 195 Fiction 20
4166 Deepshikha Mahadevi Vani 300 Poetry 10
5520 2States Chetan Rupa 250 Fiction 15
4772 Kamayani J. S. Prasad Maple 125 Classic 50
Table : ISSUED
Book_Id Qty_Issued
4166 4
9788 2
4772 2
Page 4 of 12
Write SQL query for (i) to (iv)
(i) To show book name, Author name and price of books of Maple publisher.
(ii) To show name of books of Poetry genre.
(iii) To Display the name and price of books in ascending order of their price.
(iv) To increase the price of all books of Vani publishers by 50.
Q.5
(a) Define the following:
(i) Tuple (ii) Candidate Key
(c) Consider the following tables WORKER and PAYLEVEL and answer questions (i) to
(viii) of this question:
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Mayank Shah Supervisor P001 2015-01-12 1990-12-13
12 Gaurav Shah Operator P003 2017-07-07 1992-09-28
13 Sudha Sharma Operator P003 2016-10-04 1992-02-13
15 Sangeeta Sinha Mechanic P002 2017-06-22 1993-10-09
18 Hanumant Patel Clerk P002 2015-08-25 1994-05-19
Table: PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 36000 12000
P002 28000 10000
P003 9000 6000
Page 5 of 12
Write SQL Queries for the following (i) to (iv)
(i) To display the details of all workers in descending order of DOB.
(ii) To display Name and Designation of those workers whose PLEVEL is either
P001 or P002.
(iii) To display the content of all workers whose DOB is between “19-JAN-1990‟
and 18-OCT-1992‟.
(iv) To add a new row with the following data :19, “Jayant Saini”, “Operator‟,
“P003”. “19-Jun-2018‟, “11-Jul-1995”.
Q.6
(a) Write difference between equi Join and Natural join.
(b) Consider the following tables SHOPPE and ACCESSORIES and answer the
questions (i) to (viii):
Table: SHOPPE
ID SNAME AREA
S001 ABC Computronics Akota
S002 All Infotech Media Makarpura
S003 Tech Shop Manjalpur
S004 Geeks Techno Soft Manjalpur
S005 Hitech Tech Store Makarpura
Page 6 of 12
Table: ACCESSORIES
ItemNo Name Price ID
A01 Mother Board 12000 S001
A02 Hard Disk 5000 S004
A03 Keyboard 600 S005
A04 Mouse 300 S001
A05 Mother Board 10000 S002
A06 Keyboard 700 S002
A07 Monitor 4500 S003
A08 Monitor 5500 S004
A09 Mouse 500 S002
A10 Hard Disk 3500 S001
Table: CUSTOMER
(ii) To display name of car, make and capacity of cars in descending order of
their sitting capacity.
(iii) To display the highest charges at which a vehicle can be hired from
CARDEN.
(iv) To display the customer name and corresponding name of the cars hired by
them.
Write output of the following SQL queries:
(v) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(vi) SELECT MAX(Charges), MIN(Charges) FROM CARDEN;
(vii) SELECT Make, COUNT(*) FROM CARDEN;
(viii) SELECT CarName FROM CARDEN WHERE Capacity=4;
Q.8
Page 8 of 12
(a) Expand the following:
(i) SQL (ii) RDBMS
(b) Which function do we use with cursor object to write and run SQL query in Python
and MySQL database connectivity?
Table : EMPLOYEE
ENO NAME Salary DOB GENDER DEPT
1001 Ankit 25000 1992-09-01 Male HR
1002 Saloni 60000 1991-12-15 Female R&D
1003 Sanjay 40000 1988-09-04 Male HR
1007 Harish 42000 1985-10-19 Male Production
1004 Sunita 30000 1987-11-14 Female Production
1005 Ashok 25000 1988-03-31 Male HR
1006 Namita 50000 1986-06-23 Female Production
Write SQL queries for (i) to (iv):
(i) To display Eno, Name, Gender in ascending order of ENo.
(ii) To display the name of all the female employees.
(iii) To display the Eno and Name of those employees who are born between
‘1988-01-01’ and ‘1992-12-01’.
(iv) Display the average salary of each gender.
Q.9
(a) Write difference between count( *) and count(col name ) in respect of database.
(ii) To display the name of all the female staff whose name starts with the letter
‘N’.
(iii) To display the Eno, Name and salary of those employees whose salary
between 27000 and 36000.
Write outputs of the SQL queries (v) to (viii) based on the relations
PLAYER and GAME given below:
TABLE: PLAYER
10 of 12
TABLE: GAME
Gcode Gname no_of_players Gtype
01 Tennis 1 Outdoor
02 Cricket 11 Outdoor
03 Badminton 1 Indoor
11 of 12
(ii) To display the details of all the dresses which have LAUNCHDATE in between
05-DEC-07 and 20-JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the dresses which are made up of material
with MCODE as M003.
(iv) To display material wise (MCODE) highest and lowest price of dresses from
DRESS table.
Consider the following tables GAMES and PLAYER and answer the
following parts:
Table: GAMES
Gcode GameName Type Number PrizeMoney ScheduleDate
101 Carom Board Indoor 2 5000 23-01-2004
102 Badminton Outdoor 2 12000 12-12-2003
103 Table Tennis Indoor 4 8000 15-02-2004
105 Chess Indoor 2 9000 01-01-2004
108 Lawn Tennis Outdoor 4 25000 19-03-2004
Table: PLAYER
Pcode Name Gcode
1 Atul Sharma 101
2 Pradeep Mishra 108
3 Manish Tripathi 101
4 Harish Goyal 103
12 of 12