Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
110 views10 pages

Worksheet Topic DBMS 2025-26

The document is a worksheet for Class 12th on Database Management Systems (DBMS) covering various SQL commands and concepts. It includes questions on Data Definition Language (DDL), Data Manipulation Language (DML), and practical SQL queries related to different tables. The worksheet also addresses common errors in SQL queries and requires students to write queries based on provided tables.

Uploaded by

12345krish0gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views10 pages

Worksheet Topic DBMS 2025-26

The document is a worksheet for Class 12th on Database Management Systems (DBMS) covering various SQL commands and concepts. It includes questions on Data Definition Language (DDL), Data Manipulation Language (DML), and practical SQL queries related to different tables. The worksheet also addresses common errors in SQL queries and requires students to write queries based on provided tables.

Uploaded by

12345krish0gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Worksheet Topic: DBMS Class-12th

1. What are DDL and DML? Give one command of each


2. Which command is used to add new column in existing table?
3. Which clause is used to search for NULL values in any column?
4. Which command is used to see information like name of columns, data
type, size etc.?
5. Which clause is used for pattern matching? What are the 2 main
characters used for matching the pattern?
6. Which clause is used to see the output of query in ascending or
descending order?
7. Which clause is used to see the output of query in ascending or
descending order?
8. Which clause is used to eliminate the duplicate rows from output?
9. Which command is used to remove the table from database?
10.Which command is used to add new record in table?
11.Which option of ORDER BY clause is used to arrange the output in
descending order?
12.Which command is used to change the existing information of table?
13.Raj is a database programmer, He has to write the query from
EMPLOYEE table to search for the employee whose name begins from
letter “R‟, for this he has written the query as: SELECT * FROM
EMPLOYEE WHERE NAME=‟R%‟, But the query is not producing the
correct output, help Raj and correct the query so that he gets the desired
output.
14.Raj is a database programmer, He has to write the query from
EMPLOYEE table to search for the employee who are not getting any
commission, for this he has written the query as: SELECT * FROM
EMPLOYEE WHERE commission=null; ,But the query is not producing
the correct output, help Raj and correct the query so that he gets the
desired output.
15.Raj is a database programmer, has to write the query from EMPLOYEE
table to search for the employee who are working in „Sales‟ or „IT‟
department, for this he has written the query as: SELECT * FROM
EMPLOYEE WHERE department=‟Sales‟ or “IT‟, But the query is not
producing the correct output, help Raj and correct the query so that he gets
the desired output.
16.The following query is producing an error. Identify the error and also
write the correct query. SELECT * FROM EMP ORDER BY NAME
WHERE SALARY>=5000;
17.What is the difference between Equi-Join and Natural Join?
18.Observe the given Table TEACHER and give the output of question (i)
and (ii)

TEACHER_CODE TEACHER_NAME DOJ

T001 ANAND 2001-01-30


T002 AMIT 2007-09-05
T003 ANKIT 2007-09-20
T004 BALBIR 2010-02-15
T005 JASBIR 2011-01-20
T006 KULBIR 2008-07-11

(i) SELECT TEACHER_NAME,DOJ FROM TEACHER WHERE


TEACHER_NAME=”%I%”;
(ii) SELECT * FROM TEACHER WHERE DOJ=”%-09-“;
19.Query to delete all record of table without deleting the table.
Suppose a table BOOK contain columns (BNO, BNAME, AUTHOR,
PUBLISHER), Raj is assigned a task to see the list of publishers, when he
executed the query as:
SELECT PUBLISHER FROM BOOK;
He noticed that the same publisher name is repeated in query output. What
could be possible solution to get publisher name uniquely? Rewrite the
following query to fetch unique publisher names from table.
20.Consider the following MOVIE table and write the SQL queries based on
it.

MovieI MovieName Category ReleaseDa ProductionC BusinessCo


D te ost st
001 HindiMovie Musical 2018-04- 124500 130000
23
002 TamilMovie Action 2016-05- 112000 118000
17
003 EnglishMov Horror 2017-08- 245000 360000
ie 06
004 BengaliMov Adventu 2017-01- 72000 100000
ie re 04
005 TeluguMovi Action - 100000 -
e
006 PunjabiMov Comedy - 30500 -
ie

a) Display all the information from the Movie table.


b) List business done by the movies showing only MovieID, MovieName
and Total_Earning. Total_ Earning to be calculated as the sum of
ProductionCost and BusinessCost.
c) List the different categories of movies.
d) Find the net profit of each movie showing its MovieID, MovieName and
NetProfit. Net Profit is to be calculated as the difference between Business
Cost and Production Cost.
e) List MovieID, MovieName and Cost for all movies with ProductionCost
greater than 10,000 and less than 1,00,000.
f) List details of all movies which fall in the category of comedy or action.
g) List details of all movies which have not been released yet.

21.Consider the following table named “Product”, showing details of


products being sold in a grocery shop.

PCode PName UPrice Manufacturer


P01 Washing Powder 120 Surf
P02 Toothpaste 54 Colgate
P03 Soap 25 Lux
P04 Toothpaste 65 Pepsodent
P05 Soap 38 Dove
P06 Shampoo 245 Dove

Write SQL queries for the following:


a) Create the table Product with appropriate data types and constraints.
b) Identify the primary key in Product.
c) List the Product Code, Product name and price in descending order of their
product name. If PName is the same, then display the data in ascending order
of price.
d) Add a new column Discount to the table Product.
e) Calculate the value of the discount in the table Product as 10 per cent of
the UPrice for all those products where the UPrice is more than 100,
otherwise the discount will be 0.
f) Increase the price by 12 per cent for all the products manufactured by
Dove.
g) Display the total number of products manufactured by each manufacturer.
Write the output(s) produced by executing the following queries on the basis
of the information given above in the table Product:

h) SELECT PName, avg(UPrice) FROM Product GROUP BY Pname;


i) SELECT DISTINCT Manufacturer FROM Product;
j) SELECT COUNT (DISTINCT PName) FROM Product;
k) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP
BY PName;

22.Write SQL queries for (a) to (d) based on the tables PASSENGER and
FLIGHT given below:
Table: PASSENGER
PNO NAME GENDER FNO
1001 Suresh MALE F101
1002 Anita FEMALE F104
1003 Harjas MALE F102
1004 Nita FEMALE F103

Table: FLIGHT
FNO START END FDATE FARE
F101 MUMBAI CHENNAI 2021-12-25 4500
F102 MUMBAI BENGALURU 2021-11-20 4000
F103 DELHI CHENNAI 2021-12-10 5500
F104 KOLKATA MUMBAI 2021-12-20 4500
F105 DELHI BENGALURU 2021-01-15 5000

a. Write a query to change the fare to 6000 of the flight whose FNO is F104.
b. Write a query to display the total number of MALE and FEMALE
PASSENGERS.
c. Write a query to display the NAME, corresponding FARE and FDATE of
all PASSENGERS who have a flight to START from DELHI.
d. Write a query to delete the records of flights which end at MUMBAI.
23.Consider the tables ADMIN and TRANSPORT given below:
Table: ADMIN
Sid Sname Address Stype
S001 Sandhya Rohini Day Boarder
S002 Vedanshi Rohtak Day Scholar
S003 Vibhu Raj Nagar NULL
S004 Atharva Rampur Day Boarder

Table: TRANSPORT
Sid BusNo StopName
S002 TSS10 Sarai Kale Khan
S004 TSS12 Sainik Vihar
S005 TSS10 Kamla Nagar

Write the SQL queries for the following:


a. Display the student name and their stop name from the tables ADMIN
and TRANSPORT.
b. Display the number of students whose Stype is not known.
c. Display all details of the students whose name starts with “V”.
d. Display student id and address in alphabetical order of student name,
from the table ADMIN.
24.Write the output of the SQL queries (a) to (b) based on the relations
COMPUTER and SALES given below:
Table: COMPUTER
PROUDID PRODNAME PRICE COMPANY TYPE
P001 MOUSE 200 LOGITECH INPUT
P002 LASER 4000 CANON OUTPUT
PRINTER
P003 KEYBOARD 500 LOGITECH INPUT
P004 JOYSTICK 1000 IBALL INPUT
P005 SPEAKER 1200 CREATIVE OUTPUT
P006 DESKJET 4300 CANON OUTPUT
PRINTER

Table: SALES
PRODID QTYSOLD QUARTER
P002 4 1
P003 2 2
P001 3 2
P004 2 1

a) SELECT MIN(PRICE), MAX(PRICE) FROM COMPUTER;


b) SELECT COMPANY, COUNT (*) FROM COMPUTER GROUP BY
COMPANY HAVING COUNT(COMAPANY) > 1;
c) SELECT PRODNAME, QTYSOLD FROM COMPUTER C, SALES S
WHERE C.PRODID=S.PRODID AND TYPE = “INPUT”;
d)SELECT PRODNAME, COMPANY, QUARTER FROM COMPUTER C,
SALES S WHERE C.PRODID=S.PRODID;
25. Consider the following DEPT and WORKER tables. Write SQL queries for
(a) and (d) find outputs for SQL queries € to (h):

Table: DEPT

DCODE Department CITY


D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D04 HUMAN RESOURCE MUMBAI
D05 FINANCE KOLKATA

Table: WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 GEORGE K 2013-09- 1991-09- MALE D01
02 01
1002 RYMA 2012-12- 1990-12- FEMALE D03
SEN 11 15
1003 MOHITEST 2013-02- 1987-09- MALE D05
03 04
1004 MANILA 2012-12- 1986-11- FEMALE D01
SAHAI 09 14
1005 R SAHAY 2013-11- 1987-03- MALE D02
18 31
1006 JAYA 2014-06- 1985-06- FEMALE D05
PRIYA 09 23
1007 ANIL JHA 2014-01- 1984-10- MALE D04
17 19

26. While creating a table, a constraint does not allow insertion of duplicate
values in a table?
27. Which of the following is a DML commands?
a. UPDATE b. CREATE c. ALTER d. DROP
27. In MySQL, which type of value should not be enclosed within quotation
marks?
a. DATE b. VARCHAR c. FLOAT d. CHAR
28. State True or False:
If table A has 6 rows and 3 columns, and table B has 5 rows and 2 columns,
the Cartesian product of A and B will have 30 rows and 5 columns.
(Directions: Q29 and Q30) Assertion(A) and Reason(R) based questions.
Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation of for A.
(B) Both A and R are true and R is not the correct explanation of for A.
(C) A is True but R is False
(D) A is False but R is True

29. Assertion(A): In SQL, the JOIN clause is used to combine rows from two
or more tables based on a related column between them.
Reason(R): The JOIN clause must always be used with the ON condition.
30.Assertion(A): We can retrieve records from more than one table in
MySQL.
Reason(R): Foreign key is used to establish a relationship between two
tables.
31. Which clause is used in SQL to filter the groups based on a condition?
32. What will be output of the following SQL query?
SELECT name, MAX(Salary) FROM employees GROUP BY name;
a. The maximum salary for each employee.
b. The maximum salary for each department.
c. The name of the employee with the highest salary.
d. The maximum salary of all employee combined.
33. To find the total number pf rows in a table including duplicates, which
aggregate function would you use?
a. SUM() b. COUNT()
c. MAX() d. COUNT(*)
34. What will be the output of the query?
SELECT DISTINCT department FROM employees WHERE salary>50000;
a. All distinct departments with a salary greater than 50000.
b. All departments with a salary greater than 50000 including duplicates.
c. Departments of all employees with a salary greater than 50000.
d. Distinct salaries of employees greater than 50000.
35. Consider the following table with their fields
Product (PID, Pname, Quality,Qty):
(i) Write a command to remove the Primary Key constraint from the PID
column.
(ii) Write a command to add a new column(Export_Store) with appropriate
data type.
36. What are constraints? Which constraint can be used to create a link
between two tables by making one of the columns as foreign key?
37. Write the SQL commands from (i) and (iii) on the basis of the table
INTERIORS given below:
No ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double 23/02/02 32000 15
Bed
2 Soft Touch Baby Cot 20/01/02 9000 10
3 Jerry’s Baby Cot 19/02/02 8500 10
Home
4 Comfort Double 12/01/02 15000 20
Zone Bed
5 Royal Tiger Sofa 22/02/02 30000 25

(i) To show all the information about the Baby Cot from the INTERIORS
table.
(ii) To change the price to 10000 of the item having No 3.
(iii) To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is
before “22/01/02” from the INTERIORS table in descending order of
ITEMNAME.
38. . Consider the following tables School and Admin and answer the
following questions:
Table: SCHOOL
CODE TEACHER SUBJECT DOJ PERIODS EXPERIENC
E
1001 RAVI ENGLISH 12/3/2023 24 10
SHANKAR
1009 PRIYA PHYSICS 25/03/2022 26 12
SINGH
1203 KAPIL MATHS 01/04/2018 27 15
ANAND
1045 YASHRAJ CHEMISTRY 05/11/2021 28 13
1123 SAKSHAM COMPUTER 03/04/2023 36 4
SINGH

Table: ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 MALE HOD
1045 MALE SENIOR TEACHER
1123 MALE COORDINATOR

Give the output of the following SQL queries:


(i) Select Designation Count(*) From Admin Group By Designation Having
Count(*) <2;
(ii) SELECT TEACHER FROM SCHOOL WHERE PERIODS > 25 ORDER BY
TEACHER;
Write the SQL queries of the following :
(iii) To display Teacher, Subject and Designation from the tables having
experience less than 12, according to their teacher name.
(iv) To display name of the teacher, gender and DOJ having designation is
coordinator.
39. Nisha is assigned the task of maintaining the staff data of an
organization. She has to store the details of the staff in the SQL table named
EMPLOYEES with attributes as EMPNO, NAME, DEPARTMENT, BASICSAL
to store Employee’s Identification Number, Name, Department, and Basic
Salary respectively. There can be two or more Employees with the same
name in the organization.
Based on above information answer the following questions.
i. Help Nisha to identify the attribute which should be designated as the
PRIMARY KEY. Justify your answer.
ii. Help Nisha to identify the constraint which should be applied to the
attribute NAME such that the Employees’ Names cannot be left empty or
NULL while entering the records but can have duplicate values.
iii. Write the SQL command to change the size of the attribute BASICSAL in
the table EMPLOYEES to allow the maximum value of 99999.99 to be
stored in it.
iv. Write the SQL command to delete the table EMPLOYEES.
40. Table: WORKER
WID WNAME WAGE HOURS TYPE SITEID
W01 Ahmed J 1500 200 Unskilled 103
W11 Naveen S 520 100 Skilled 101
W03 Jacob B 780 95 Unskilled 101
W15 Nihal K 560 110 Semiskilled NULL
W10 Anju S 1200 130 Skilled 103

(A) Based on the data given below above, answer the following questions:
i. Write the SQL statement to display the names and wages of those
workers whose wages are between 800 and 1500.
ii. Write the SQL statement to display the record of workers whose SITEID
is not known.
iii. Write the SQL statement to display WNAME, WAGE and HOURS of all
those workers whose TYPE is “Skilled”.
iv. Write the SQL statement to change the WAGE to 1200 of the workers
where the type is “Semiskilled”.
(B) Considering the above given table WORKER, write the output on
execution of the following SQL commands:
I. SELECT WNAME, WGAE*HOURS FROM WORKER WHERE SITEID=103;
II. SELECT COUNT (DISTINCT TYPE) FROM WORKER;
III. SELECT MAX(WAGE), MIN(WAGE), TYPE FROM WORKER GROUP BY
TYPE;
IV. SELECT WNAME, SITEID FROM WORKER WHERE TYPE=”Unskilled”
ORDER BY HOURS;
41. Assume that you are working in the IT Department of a Creative Art
Gallery (CAG), which sells different forms of art creations Like Paintings,
Sculptures, etc. The data of Art creations and articles are kept in tables
Articles and Artists respectively. Following are few records from these
two tables:
Table: Articles
Code A_Code Article DOC Price
PL001 A0001 Painting 2018-10-19 20000
SC028 A0004 Sculpture 2021-01-15 16000
AL005 A0003 Quiling 2024-04-24 3000

Table: Artists
A_Code Name Phone Email DOB
A0001 Roy 595923 [email protected] 1986-10-
12
A0002 Ghosh 1122334 [email protected] 1972-02-
05
A0003 Gargi 121212 [email protected] 1996-03-
22
A0004 Mustafa 3333333 [email protected] 2000-01-
01

Note: 1. The tables contain many more records than shown here.
2. DOC is Date of Creation of an Article.
As an employee of CAG, you are required to write the SQL queries for the
following:
i. To display all the records from the Articles table in descending order of
price.
ii. To display the details of Articles which were created in the year 2020.
iii. To display the structure of Articles table.
iv. To display the name of all artists whose Article is Painting through Equi
Join.
v. To display the name of all Artists whose Article is “Painting” through
Natural Join.

You might also like