DBMS
DBMS
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’.
2. 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
a. Display the NAME and DESIGNATION of those female Employees whose pay
level is P06.
b. Display name of employees whose name has letter ‘a’ as the second
character.
c. To display the name of those employees whose age is between 01-01-1992
and 31-12-1996.
d. Display name of all employees in alphabetic order.
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
Table : ISSUED
Book_Id Qty_Issued
4166 4
9788 2
4772 2
5. 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
6.
(a) 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
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
CNO CNAME CODE
C05 Shilpi Ramteke 503
C18 Deepali Shah 509
C06 Priyakshi Yadav 502
C11 Sonam Deshkar 510
Q.8
(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?
Q.9
(a) Write difference between fetchone( ) and fetchall( ) in respect of database.
Table : STAFF
ENO NAME Salary DOB GENDER DEPT
E01 Harsh 26000 1992-09-01 Male Marketing
E02 Divya 52000 1991-12-15 Female Marketing
E03 Sujata 41000 1988-09-04 Female HR
E04 Meenal 32000 1985-10-19 Female Production
E05 Akanksha 22000 1987-11-14 Female IT
E06 Arun 15000 1988-03-31 Male IT
E07 Sharmila 10000 1986-06-23 Female Production
Write SQL queries for (i) to (iv):
(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
Pcode Pname Gender DOB State Gcode
401 Ravita F 2000-10-09 Punjab 03
402 Gauravi F 2001-01-22 Bihar 02
403 Rakesh M 2000-11-29 Haryana 01
404 Divya F 2002-05-12 Rajasthan 02
405 Hemali F 2000-09-21 Gujarat 01
406 Ashok M 2000-12-12 Rajasthan 03
TABLE: GAME
Gcode Gname no_of_players Gtype
01 Tennis 1 Outdoor
02 Cricket 11 Outdoor
03 Badminton 1 Indoor
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
Give the output of the following SQL queries:
G.PrizeMoney>10000;