📝 Unit 3 Board Questions + Practice
Unit 3 of the 2026-27 syllabus carries 20 marks. Part A has 24 new practice questions with answers (click "Show answer" only after you try). Part B has all 27 questions of Unit 3 from the previous CBSE board papers (2022, 2023, 2026) in their original form – tables, code and internal choices included – each with a worked answer.
1) Read the unit lessons first. 2) Solve Part A in your notebook, then check answers. 3) Attempt Part B paper-wise with a timer – about 1.5 minutes per mark. 4) Mark the questions you got wrong and revise that lesson again.
Part A – Practice questions with answers
A relation has 8 rows and 5 columns. State its cardinality and degree.
Show answer
Cardinality 8; degree 5.
A table has three candidate keys and one is selected as primary. How many alternate keys remain?
Show answer
2.
Which command can add an attribute to an existing table?
Show answer
ALTER TABLE … ADD (e.g. ALTER TABLE STUDENT ADD City VARCHAR(20);)
A table has 6 rows, with 2 NULL values in Phone. State COUNT(*) and COUNT(Phone).
Show answer
6 and 4.
Which clause filters grouped results: WHERE or HAVING?
Show answer
HAVING.
Under the default tuple-returning cursor, what Python structure does fetchall() return?
Show answer
A list of tuples.
Explain candidate key and foreign key using STUDENT(SID,Name,CID) and CLASS(CID,ClassName). Assume SID and CLASS.CID uniquely identify records.
Show answer
SID is a candidate key of STUDENT; CLASS.CID is a candidate key of CLASS. STUDENT.CID can be a foreign key referencing CLASS.CID, linking students to classes.
Differentiate CHAR(10) and VARCHAR(10). State the purpose of NOT NULL and UNIQUE.
Show answer
CHAR is fixed-length character data; VARCHAR is variable-length up to its declared length. NOT NULL rejects missing values; UNIQUE prevents duplicate non-NULL key values, subject to DBMS rules for NULL.
Write commands to create database SCHOOL, select it, show its tables and display the structure of STUDENT.
Show answer
CREATE DATABASE SCHOOL; USE SCHOOL; SHOW TABLES; DESCRIBE STUDENT;
Correct the query to find departments having more than two employees.
SELECT Dept, COUNT(*) FROM EMPLOYEE WHERE COUNT(*) > 2 GROUP BY Dept;
Show answer
SELECT Dept,COUNT(*) FROM EMPLOYEE GROUP BY Dept HAVING COUNT(*)>2;
| SID | Name | House | Marks | City |
|---|---|---|---|---|
| 1 | Asha | Red | 84 | Khurja |
| 2 | Bilal | Blue | 76 | Aligarh |
| 3 | Charu | Red | 92 | Khurja |
| 4 | Dev | Blue | NULL | Delhi |
| 5 | Esha | Green | 68 | Aligarh |
| 6 | Farhan | Red | 80 | Khurja |
Write queries to display (i) Name and Marks for Marks BETWEEN 75 AND 85, (ii) records from Khurja or Delhi using IN, (iii) names ending in a.
Show answer
SELECT Name,Marks FROM STUDENT WHERE Marks BETWEEN 75 AND 85;
SELECT * FROM STUDENT WHERE City IN ('Khurja','Delhi');
SELECT Name FROM STUDENT WHERE Name LIKE '%a';Write queries to display (i) records with missing Marks, (ii) distinct cities alphabetically, (iii) names and marks in descending Marks order.
Show answer
SELECT * FROM STUDENT WHERE Marks IS NULL; SELECT DISTINCT City FROM STUDENT ORDER BY City; SELECT Name,Marks FROM STUDENT ORDER BY Marks DESC;
Predict (i) COUNT(*) and COUNT(Marks), (ii) MIN(Marks) and MAX(Marks), (iii) SUM(Marks) for Red house.
Show answer
(6,5); (68,92); 256.
Write queries for (i) house-wise student counts, (ii) house-wise average Marks with alias AverageMarks, (iii) houses with average Marks > 80.
Show answer
SELECT House,COUNT(*) FROM STUDENT GROUP BY House; SELECT House,AVG(Marks) AS AverageMarks FROM STUDENT GROUP BY House; SELECT House,AVG(Marks) FROM STUDENT GROUP BY House HAVING AVG(Marks)>80;
Independently (i) insert (7,Gauri,Green,88,Delhi), (ii) increase Red-house marks by 2, (iii) delete SID 4, (iv) display Name and Marks+5 with alias Adjusted for non-NULL Marks.
Show answer
INSERT INTO STUDENT VALUES(7,'Gauri','Green',88,'Delhi'); UPDATE STUDENT SET Marks=Marks+2 WHERE House='Red'; DELETE FROM STUDENT WHERE SID=4; SELECT Name,Marks+5 AS Adjusted FROM STUDENT WHERE Marks IS NOT NULL;
| CID | CName | Fee |
|---|---|---|
| C1 | Python | 4000 |
| C2 | SQL | 3500 |
| C3 | Networks | 3000 |
| EID | Learner | CID |
|---|---|---|
| 101 | Aman | C1 |
| 102 | Bhavna | C2 |
| 103 | Chirag | C1 |
| 104 | Diya | C3 |
Write equi-join queries to show (i) each learner and course name, (ii) learner and Fee where Fee >= 3500, (iii) learner count for each course.
Show answer
SELECT E.Learner,C.CName FROM ENROL E,COURSE C WHERE E.CID=C.CID; SELECT E.Learner,C.Fee FROM ENROL E,COURSE C WHERE E.CID=C.CID AND C.Fee>=3500; SELECT C.CName,COUNT(*) FROM ENROL E,COURSE C WHERE E.CID=C.CID GROUP BY C.CName;
How many rows and columns result from (i) COURSE CROSS JOIN ENROL, (ii) COURSE NATURAL JOIN ENROL? CID is their only common column.
Show answer
Cross join: 12 rows, 6 columns. Natural join: 4 rows, 5 columns.
Predict this result, then explain why CID must be the intended common joining attribute.
SELECT Learner,CName FROM COURSE NATURAL JOIN ENROL ORDER BY Learner;
Show answer
Aman Python; Bhavna SQL; Chirag Python; Diya Networks. NATURAL JOIN joins on all identically named columns; here CID is the only common name and represents the course identifier.
Create BOOK(BookID INT,Title VARCHAR(40),Price FLOAT,PurchaseDate DATE), making BookID the primary key and Title NOT NULL. Then write commands to add Shelf CHAR(5), remove Shelf, and drop BOOK. Treat the final three operations sequentially.
Show answer
CREATE TABLE BOOK(BookID INT PRIMARY KEY, Title VARCHAR(40) NOT NULL, Price FLOAT, PurchaseDate DATE); ALTER TABLE BOOK ADD Shelf CHAR(5); ALTER TABLE BOOK DROP COLUMN Shelf; DROP TABLE BOOK;
For an existing ITEM table whose ItemID values are unique and non-NULL, add a primary key on ItemID, then remove that primary key. Give commands to show all databases and drop a practice database named TEMPDB.
Show answer
ALTER TABLE ITEM ADD PRIMARY KEY(ItemID); ALTER TABLE ITEM DROP PRIMARY KEY; SHOW DATABASES; DROP DATABASE TEMPDB;
Use these as written exercises on a practice database only.
Write a complete Python program to connect to a local MySQL database SCHOOL using practice credentials user="student", password="practice" and display STUDENT rows with Marks >= 80. Use execute(), fetchall() and close the cursor and connection.
Show answer
Assumes mysql.connector and the stated local practice database/account are available:
import mysql.connector as mysql
con = mysql.connect(host='localhost',user='student',
password='practice',database='SCHOOL')
cur = con.cursor()
cur.execute('SELECT * FROM STUDENT WHERE Marks >= %s',(80,))
for row in cur.fetchall():
print(row)
cur.close()
con.close()Using an established connection con and cursor cur, accept SID and new Marks, update the matching student using parameter placeholders, commit, and print the affected-row count.
Show answer
One valid solution:
sid = int(input('SID: '))
marks = int(input('New marks: '))
cur.execute('UPDATE STUDENT SET Marks=%s WHERE SID=%s',
(marks,sid))
con.commit()
print(cur.rowcount)Using con and cur, insert (7,Gauri,Green,88,Delhi) with a parameterized query and commit. Then delete SID 7 with a parameterized query and commit. Explain the purpose of commit().
Show answer
commit() finalizes the transaction changes in this transactional example.
cur.execute('INSERT INTO STUDENT VALUES(%s,%s,%s,%s,%s)',
(7,'Gauri','Green',88,'Delhi'))
con.commit()
cur.execute('DELETE FROM STUDENT WHERE SID=%s',(7,))
con.commit()With the original STUDENT data from U3-11, predict each print using the default cursor. Explain what fetchone() returns after exhaustion.
cur.execute('SELECT SID,Name FROM STUDENT ORDER BY SID')
print(cur.fetchone())
print(cur.fetchone())
rest = cur.fetchall()
print(len(rest))
print(cur.fetchone())Show answer
(1, 'Asha'); (2, 'Bilal'); 4; None. fetchone() returns None when no rows remain.
Part B – Previous year board questions (Unit 3)
CBSE Board Paper 2026 – 10 questions

Show answer
(B) 1

Show answer
(B) ALTER TABLE

Show answer
(D) ID and name of machines with quantity less than or equal to 100 from INVENTORY table.

Show answer
(C) 6 – cardinality is the number of tuples: 2 + 4 = 6 (deleting attributes changes only the degree).

Show answer
(A) MIN()

Show answer
(C) – Assertion is true, Reason is false: a primary key is chosen from the candidate keys.

Show answer
(i) (a)
CREATE TABLE W_STOCK (
W_Code CHAR(5) PRIMARY KEY,
W_Description VARCHAR(20),
B_Qty INT,
U_Price FLOAT
);OR (b) No. Different items can have the same unit price, so U_Price is not unique and cannot identify each record.
(ii) (a)
ALTER TABLE W_STOCK ADD E_Date DATE;
OR (b)
ALTER TABLE W_STOCK DROP COLUMN B_Qty;


Show answer
(a)
SELECT Type, MAX(Price) FROM STOCK GROUP BY Type; -- (i) UPDATE STOCK SET Price = Price + 0.5 WHERE Type = 'F'; -- (ii) SELECT SUM(Qty * Price) FROM STOCK; -- (iii) SELECT * FROM STOCK WHERE Code LIKE 'A%'; -- (iv)
OR (b)
(i) 0.5 300 38.00; 0.5 250 36.50; 1.0 50 52.00
(ii) AF0.5 300; MF0.5 250; PT0.5 78
(iii) F, T, D
(iv) 0.5 → 3; 1.0 → 3


Show answer
SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0; -- (i) SELECT C.C_Name FROM CUSTOMERS C, LOANS L WHERE C.C_ID = L.C_ID AND L.L_Amt > 1000000; -- (ii) SELECT C.C_ID, C.C_Name, L.Terms FROM CUSTOMERS C, LOANS L WHERE C.C_ID = L.C_ID AND L.L_Date > '2024-12-31'; -- (iii) SELECT * FROM LOANS ORDER BY RoI DESC; -- (iv)(a) SELECT C_ID, AVG(Terms) FROM LOANS GROUP BY C_ID; -- OR (iv)(b)

Show answer
import mysql.connector as mysql
con = mysql.connect(host="localhost", user="admin", password="root", database="SCHOOL")
cur = con.cursor()
cur.execute("SELECT * FROM Account WHERE Fees < %s", (5000,))
for row in cur.fetchall():
print(row)
cur.close()
con.close()CBSE Board Paper 2023 – 9 questions

Show answer
(d) Cardinality

Show answer
(b) ORDER BY

Show answer
(b) List of tuples

Show answer
Candidate keys that are not chosen as the primary key are called alternate keys. Example: in STUDENT(AdmNo, RollNo, AadhaarNo, Name), AdmNo and AadhaarNo are both unique (candidate keys). If AdmNo is made the primary key, AadhaarNo becomes an alternate key.

Show answer
(a) CHAR(n) is fixed-length: it always uses n characters, padding with spaces (CHAR(10) storing 'Ram' uses 10 characters). VARCHAR(n) is variable-length: it uses only the space needed up to n (VARCHAR(10) storing 'Ram' uses 3 characters). CHAR suits fixed codes (e.g. PIN, gender); VARCHAR suits names/addresses.
OR (b) DDL: CREATE, ALTER (also DROP). DML: INSERT, UPDATE (also DELETE, SELECT).


Show answer
(a) Natural join on LOAN_NO gives 2 rows (L-170 RAVYA, L-230 KRISH) and 4 columns (LOAN_NO, B_NAME, AMOUNT, CUST_NAME).
(b)
(i) STATE in descending order: SAHIL KANPUR, VEDA KANPUR, SAMEER ROOP NAGAR, MAHIR SONIPAT, MARY DELHI, ATHARVA DELHI (rows of the same state may appear in any order)
(ii) KANPUR, ROOP NAGAR, DELHI, SONIPAT
(iii) SAHIL UTTAR PRADESH; MAHIR HARYANA; VEDA UTTAR PRADESH (second and third letters 'HA': KHAN, SHARMA)
(iv) KANPUR 2; ROOP NAGAR 1; DELHI 2; SONIPAT 1

Show answer
(a)
(i) MIN = 200, MAX = 4300
(ii) LOGITECH 2; CANON 2
(iii) KEYBOARD 2; MOUSE 3; JOYSTICK 2
(iv) LASER PRINTER CANON 1; KEYBOARD LOGITECH 2; MOUSE LOGITECH 2; JOYSTICK IBALL 1
(b)
SHOW DATABASES;



Show answer
Delete version:
import mysql.connector as mysql # Statement 1
mycursor.execute("DELETE FROM employee WHERE E_code = 'E101'") # Statement 2
mydb.commit() # Statement 3OR – Display version:
import mysql.connector as mysql # Statement 1
mycursor.execute("SELECT * FROM employee WHERE City = 'Delhi'") # Statement 2
details = mycursor.fetchall() # Statement 3
Show answer
(i) LABNO and LAB_NAME (both unique for every lab).
(ii) Degree = 5, Cardinality = 5
(iii)
INSERT INTO LAB VALUES ('L006', 'PHYSICS', 'Ravi', 25, 'II'); -- (a)
UPDATE LAB SET CAPACITY = CAPACITY + 10 WHERE FLOOR = 'I'; -- (b)OR (iii)
ALTER TABLE LAB ADD PRIMARY KEY (LABNO); -- (a) DROP TABLE LAB; -- (b)
CBSE Board Paper 2022 (Term-2, 35 marks) – 8 questions

Show answer
An attribute is a column (field) of a relation, e.g. Name in STUDENT. A domain is the set of all allowed values that an attribute can take, e.g. the domain of Gender is {M, F}. Every attribute takes its values from its domain.

Show answer
The first fetchone() reads M1001 (not printed); the loop then fetches and prints the next two GYM rows:
M1002#Pratik M1004#Rakesh

Show answer
(a) Harjot 55; Srikanth 43
(b) Delhi 2; Kolkata 1; Mumbai 2
(c) Delhi, Mumbai, Kolkata
(d) MAX(Dose1) = 2022-01-01, MIN(Dose2) = 2021-07-20


Show answer
(a) Natural join on DNO (P3 has NULL, so it is left out):
AMITABH NOOR; ANIKET ANNIE; AMITABH HARMEET
(b) NOOR 2021-12-25 1500; HARMEET 2019-12-20 1500


Show answer
A candidate key is any attribute (or set of attributes) that can uniquely identify each tuple of a relation; a table may have several. The primary key is the one candidate key chosen by the designer to identify the tuples; it cannot be NULL. The remaining candidate keys are alternate keys.
OR (a) PNO (b) Degree is the number of attributes (columns) of a relation. Degree of PLAYER = 3.

Show answer
(i)
ALTER TABLE ITEMS DROP COLUMN DISCOUNT;
(ii) DDL: CREATE, DROP. DML: UPDATE, INSERT.

Show answer
USE LIBRARY; -- (a) SHOW TABLES; -- (b) DESCRIBE BOOKS; -- (c)


Show answer
UPDATE FLIGHT SET FARE = 6000 WHERE FNO = 'F104'; -- (a) SELECT GENDER, COUNT(*) FROM PASSENGER GROUP BY GENDER; -- (b) SELECT P.NAME, F.FARE, F.F_DATE FROM PASSENGER P, FLIGHT F WHERE P.FNO = F.FNO AND F.START = 'DELHI'; -- (c) DELETE FROM FLIGHT WHERE END = 'MUMBAI'; -- (d)
Next: prepare your Practical File and choose a Project.
