N.S.N.
MEMORIAL SENIOR SECONDARY SCHOOL
Thirumurugan Salai, Thirumurugan Nagar, Chitlapakkam, Chennai – 600064
QUESTION BANK (2024 – 25)
Class: XII Unit 3: DATABASE and INTERFACE Subject: Computer Science
I. Answer the following in a word/sentence(1 Mark)
1. Write about the terms degree and cardinality of a table.
2. Differentiate between DROP and DELETE commands of SQL.
3. Fill in the blank:
4. A database is a special control structure that facilitates the row by row processing of
records in the result set.
(a) fetch b) table c) cursor d) query
5. The following SQL is which type of join:
select customer. cust_id, order. cust_id, name, order_id from customer, order;
6. Which command is used to add new column in existing table?
7. Which clause is used to search for NULL values in any column?
8. Which command is used to add new record in table?
9. Which command is used to remove the table from database?
10.What is the minimum number of columns required in MySQL to create table?
11.Which clause is used to eliminate the duplicate rows from output?
12.Which clause is used to see the output of query in ascending or descending order?
13.Which clause is used for pattern matching? What are the 2 main characters used for
matching the pattern?
14.Which clause is used to see information like name of columns, data type, size etc.?
15.What is the difference between Equi-join and Natural Join?
16.What is the full form of SQL?
17.Which SQL function is used to get the average value of any column?
18.What is the difference between COUNT( ) and COUNT( *) function?
19. Fill in the blank:
Constraint is used to restrict entries in other table’s non key attribute, whose values are
not
existing in the primary key of reference table.
20.The........keyword sorts the records in ascending order by default.
(a) LIKE (b) UPDATE (c) ORDER (d) ORDER BY
21.Fill in the blank
_______ command is used to modify the attribute datatype or size in a table structure.
an entity
22. Which of the following statements is FALSE in a relational database?
a) Any candidate key is eligible to become a primary key.
b) Data dictionary is a file containing metadata. i.e, data about data.
c) A candidate key that is not a primary key is a foreign key.
d) Foreign key is a non-key attribute, whose values are derived from the primary key
of
some other table.
23.The purpose of the primary key in a database is to
(a) unlock the database
(b) provide a map of the data
(c) uniquely identify a record
(d) establish constraints on database operations
1
24. The rule of referential integrity is based on...........
(a) Primary key (b) Foreign
25.____________command adds a primary key to a table after it has been already created.
(a) MODIFY (b) ADD PRIMARY (c) ALTER (d) ADD KEY
26.The clause to get the unique values from a field of a table is
(a) MAX (b) UNIQUE (c) DISTINCT (d) None of these
27. __________is an attribute that makes a link between two tables to fetch corresponding
data.
(a) Primary key (b) Secondary key (c) Foreign key (d) Composite key
28. Which of the following SQL commands displays the structure of a table?
(a) ALTER (b) STRUCTURE (c) DESCRIBE (d) SHOW DATA
29.__________command adds a primary key to a table after it has been already created.
(a) MODIFY (b) ADD PRIMARY (c) ALTER (d) ADD KEY
30.The clause to get the unique values from a field of a table is
(a) MAX (b) UNIQUE (c) DISTINCT (d) None of these
31.If a table carries 10 columns and 15 rows, what is its degree?
(a) 10 (b) 150 (c) 15 (d) 25
32.Rows of a relation are called
(a) relation (b) tuples (c) data structure (d)key (c) Alternate key
(d) None of these
33. Which of the following command displays the attributes of a table along with their types
and sizes?
(a) Alter (b) Show structure (c) Show create table (d) View structure
34.The............command adds records to a table.
(a) ADD (b) APPEND c) ADDRECORD (d) INSERT
35. The..........clause can be used as an alternative to multiple OR.
(a) IN (b) BETWEEN (c) NOT (d) range
36.Which of the following SQL commands displays the structure of a table?
(a) ALTER (b) STRUCTURE (c) DESCRIBE (d) SHOW DATA
37.Which of the following is a correct syntax to add a column in SQL command?
(a) ALTER TABLE table_name ADD column_name data_type;
(b) ALTER TABLE ADD column_name data_type;
(c) ALTER table_name ADD column_name data_type;
(d) none of these
38.The constraint that is used to provide a condition on a field to take specific values only
is :
(a) NULL (b) PRIMARY KEY (c) CHECK (d) NOT NULL
39.Identify any two DML commands from the following and also explain.
ALTER, INSERT, UPDATE, DROP, CREATE
40.A column storing the Name of a department in a table Emp will be of type
(a) int (b) date (c) float (d) varchar
II. Answer the following (2 Marks):
41.Differentiate between an attribute and a tuple with an example.
42.Differentiate between an attribute and a tuple with an example.
43. Describe the following terms
(i) Domain (ii) DB2
44. Identify commands/functions for the following actions :
(i) To add a new column to a table.
(ii) To get the sum of all values in a column of a table.
45.Write the code to create a table Product in database Inventory with following fields
Fields Datatype
2
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory
46.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 TAEACHER_NAME LIKE ‘%I%’;
(II) SELECT * FROM TEACHER WHERE DOJ LIKE ‘%-09-%’;
47.Consider the tables CARS and SUPPLIER given below. What will be the output of the
statement given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4
Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE C.Scode= S. Scode
AND Charges > 15;
48. Write the output for SQL queries (i) to (iv), which are based on the table CARDEN.
TABLE: CARDEN
Ccode CarName Make Color Capa-city Charges
501 A-star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT COUNT(*) Make FROM CARDEN;
(iii) SELECT CarName FROM CARDEN WHERE Capacity = 4;
(iv) SELECT SUM (Charges) FROM CARDEN WHERE Color = “SILVER”;
49. Identify commands/functions for the following actions :
To add a new column to a table.
3
To get the sum of all values in a column of a table.
50.Describe the following terms
(i) Domain (ii) DB2
III. Answer the following questions (3 Marks)
51. Consider the following tables - STUDENT and STREAM :
TABLE: STUDENT
SCODE NAME AGE STRCDE POINTS GRADE
101 Amit 16 1 6 NULL
102 Arjun 13 3 4 NULL
103 Zaheer 14 2 1 NULL
TABLE: STREAM
STRCDE STRNAME
1 SCIENCE+COMP
2 SCIENCE+ BIO
3 SCIENCE+ECO
4 COMMERCE+MATHS
a. What will be the output of the following statement?
SELECT NAME, STRNAME FROM STUDENT S, STREAM ST WHERE S.STRCDE=ST.STRCDE;
52. Consider the tables CARS and SUPPLIER given below. What will be the
output of the statement given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4
Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE C.Scode= S. Scode
AND Charges > 15;
IV. Answer the following questions (4 Marks)
53.Consider the following tables GARMENT and FABRIC. Write SQL commands for the
statements (i) to (iv).
TABLE: GARMENT
GCODE DESCRI-PTION PRICE FCODE READY-DATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08
10012 INFORMAL SHIRT 1550 F02 06-JUN-08
10024 BABY TOP 750 F03 07-APR-07
10090 TULIP SKIRT 850 F02 31-MAR-07
10019 EVENING GOWN 850 F03 06-JUN-08
10009 INFORMAL PANT 1500 F02 20-OCT-08
4
10007 FORMAL PANT 1350 F01 09-MAR-08
10020 FROCK 850 F04 09-SEP-07
10089 SLACKS 750 F03 20-OCT-08
TABLE: FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(ii) To display the details of all the GARMENTs, which have READYDATE in between 08-
DEC-07 and 16-JUN-08 (inclusive of both the dates).
(iii)To display the average PRICE of all the GARMENTs. Which are made up of FABRIC with
FCODE as F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs from GARMENT table.
(Display FCODE of each GARMENT along with highest and lowest price.)
54. Write the output of the queries (i) to (iv) based on the table FURNITURE given below.
Table : FURNITURE
FID NAME DATE OF PURCHASE COST DISCOUNT
B001 Double Bed 03-JAN-2018 45000 10
T010 Dinning Table 10-MAR-2020 51000 5
B004 Single Bed 19-JUL-2021 22000 0
C003 Long back Chair 30-DEC-2016 12000 3
T006 Console Table 17-NOV-2019 15000 12
B006 Bunk bed 01-JAN-2021 28000 14
(i) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;
(ii) SELECT MAX(DATEOFPURCHASE) FROM FURNITURE;
(iii)SELECT * FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE “T%”;
(iv) SELECT DATEOFPURCHASE FROM FURNITURE WHERE NAME IN (“Dinning Table”, “Console
Table”);
55. Write the output of the queries (i) to (iv) based on the table,
TECH_COURSE given below:
i) SELECT DISTINCT TID FROM TECH_COURSE;
ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID
HAVING COUNT(TID)>1;
iii) SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY CNAME;
iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000 AND 17000;
5
56. Write the output for SQL queries (i) to (iv), which are based on the table ITEMS.
TABLE: ITEMS
Code IName Qty Price Company TCode
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1004 CAR GPS SYSTEM 50 2150 GEOKNOW T01
1005 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02
1005 PEN DRIVE 32 GB 600 1200 STOREHOME T03
(i) SELECT MAX(Price), MIN(Price) FROM ITEMS;
(ii) SELECT Price * Qty AS AMOUNT FROM ITEMS WHERE Code=1004;
(iii) SELECT DISTINCT TCode FROM ITEMS;
(iv) SELECT MAX(Company) FROM ITEMS WHERE Price > 7000;
Understanding & Remembering Level of questions Percentage 40%
Application-Level of questions Percentage 30%
Analyzing-Level of questions Percentage 30%
**********************