VIDYAA VIKAS INTERNATIONAL SCHOOL (CBSE)
GANDARVAKOTTAI
CLASS XII
SUBJECT: COMPUTER SCIENCE (083)
QUESTIONBANK
Maximum Marks: 70 Time Allowed: 3hours
SET B
SECTION A
(1X21=21)
1. Which function is used to count number of records from a table in a database?
(A) total() (B) total(*) (C) return(*) (D) count(*)
2. The SELECT statement when combined with ________ clause, returns records
without repetition.
(A) DISTINCT (B) DESCRIBE (C) UNIQUE (D) ALL
3. What will be the order of the data being sorted after the execution of given query
SELECT * FROM STUDENT ORDER BY ROLL_NO;
a)Custom Sort b) Descending c) Ascending d) None of the above
4. Where and Having clauses can be used in SELECT queries?
a) True b) False c) Only in views d) With order by
5. . ……… operation is required when you want to rectify mistakes in your records
into a database’s table.
(a) alter (b) Delete (c) None (d) Insert
6. Which of the following command is used to delete database?
(a) CREATE (b) SELECT (c) DROP (d) None of these
7. Which of the following is a correct syntax to add a column in SQL command?
(a) ALTER TABLE table_name ADD column_namedata_type;
(b) ALTER TABLE ADD column_namedata_type;
(c) ALTER table_name ADD column_namedata_type;
(d) None of the above
8. _________ can be used to return only different values in a particular column
whole table?
(a) WHERE (b) DISTINCT (c) ALL (d) BETWEEN
9. The ……… command arrange the records in descending.
(a) LIKE (b) UPDATE (c) sort (d) ORDER BY
10. The clause used to check complete records is
(a) IS NULL (b) IS NOT NULL(c) Both (a) and (b)
(d) None of the above
11. The.............. Operator is used for finding matching of values.
(a) BETWEEN (b) LIKE (c) IN (d) LOOKSLIKE
12. To remove records from a table “Product” thecommand will be
(a) remove FROM Product; (b) Drop table Product;
(c) REMOVE ALL FROM Product; (d) None;
13. The.............. character displays all the columns of atable in a SELECT query.
(a) # (b) @ (c) * (d) /
14. The “SET” clause is used along with.............. Command.
(a) DELETE (b) DESCRIBE (c) CREATE (d) UPDATE
15. Which operator is used to compare a value to a specified list of values?
(a) ANY (b) BETWEEN(c) ALL (d) IN
16. Which of the following function count all the values except NULL?
(a) COUNT(*) (b) COUNT(column_name)
(c) COUNT(NOT NULL) (d) COUNT(NULL)
17. What is the meaning of “GROUP BY” clause inMySQL?
(a) Group data by column values(b) Group data by row values
(c) Group data by column and row values(d) None of the mentioned
18. Which command is used to display the table definition ofexisting tables?
(a) displaytables; (b) desc (c) show tables; (d) output tables;
19. Expand DDL _____________
ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A.
(c) A is True but R is False
(d) A is false but R is True
20. Assertion ( A): In SQL, the aggregate function sum() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental
arithmetic tasks such as min(), max(), sum() etc
21. Assertion ( A): In SQL, the aggregate function min() calculates the minimum
value.
Reason ( R): The aggregate functions are used to perform some fundamental
calculation such as min(), max(), sum() etc
SECTION B
(2X7=14)
22. Differentiate between having and group by clause in SQL with appropriate
example.
23. What is the similarity and difference between alternate and PRIMARY KEY
constraints?
24. What is the difference between degree and cardinality of a table? What is the
degree and cardinality of the following table?
EMPNO ENAME SALARY
1101 Pramod 58000
25. In the following query how many rows will be deleted?
DELETE from Student
WHERE Student_ID=101;
(Assuming a Student table with primary key Student_ID)
26. With respect to the following table structure write queries for the following
GameIDGName Type Players
(i) To display the details of games of “INDOOR” type.
(ii) To display GName& Players for games where players is less than 2.
27. 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;
28. to create a table Product in database Inventory with following fields :
Fields Datatype
PID varchar(15)
PName varchar(30)
Price float(16,3)
SECTION C
(3X3=9)
29. Consider the following tables WORKER and PAYLEVEL and answer the
following parts of this question:
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 RadheShyam SupervisorP001 13-09-2004 23-08-1981
12 ChanderNath Operator P003 22-02-2010 12-07-1987
13 Fizza Operator P003 14-06-2009 14-10-1983
15 Ameen Ahmed Mechanic P002 19-12-2005 13-03-1983
18 Sanya Clerk P002 19-12-2005 09-06-1983
Table: PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
Give the output for the following SQL queries:
(i) SELECT COUNT(PLEVEL) FROM WORKER GROUP BY PLEVEL;
(ii) SELECT MIN(DOB), MAX(DOJ) FROM WORKER;
(iii) SELECT * FROM WORKER W, PAYLEVEL P
WHERE [Link]=[Link] AND [Link]>=13
30. Table: EMPLOYEES
Empid Firstname Lastname Address City
010 Ravi Kumar Raj nagar GZB
105 Harry Waltor Gandhi nagar GZB
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends street New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Ritu Tondon Shastri Nagar GZB
400 Rachel Lee 121 Harrison St. New York
441 Peter Thompson 11 Red Road Paris
Table: EMPSALARY
Empid Salary Benefits Designation
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
400 32000 7500 Salesman
441 28000 7500 salesman
501 18000 6500 Clerk
Give the Output of following SQL commands:
(i) Select [Link], empsalary,salary from employees, empsalary
where designation = ‘Manager’ and [Link]=[Link];
(ii) Select count(designation) from empsalary;
(iii) Select designation, avg(salary) from empsalary group by designation
havingcount(*) >1;
31. Consider the following table GARMENT, write SQL commands for the
statements (i) to (v).
Table : GARMENT
GCODE DESCRIPTION PRICE FCODE READYDATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08
10012 I NFORMAL 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
(i) To display GCODE and DESCRIPTION of each GARMENT in order of GCODE.
(ii) To display the details of all the GARMENT, which have READYDATE in between
08-DEC-07 and 16-JUN-08 (inclusive if boththe dates).
(iii) To display the average PRICE of all the GARMENT, which are made up of fabric
with FCODE as F03.
Section D
(4X4=16)
32. In a database High sports there are two tables: students and sports with the
instances given below:
Table: STUDENTS
ADMNO NAME CLASS GRADE RNO ADDRESSPHONE
1211 MEENA 12A D 4 A-26 3245678
1212 VANI 10A D 1 B-25 5456789
1213 MEENA 12B A 1 NULL NULL
1214 KARISH 10B B 3 AB-234 4567890
Table: SPORTS
ADMNO GAME COACHNAME GRADE
1215 CRICKET [Link] A
1213 VOLLEYBALL [Link] B
1211 VOLLEYBALL [Link] A
1212 BASKETBALL [Link] B
Write the SQL queries for the following statements:
(i) To display name and game of those students whose address is not available in
students table.
(ii) To delete records from the table students.
(iii) To display names of those students who are not studying in class 12 and their
corresponding coach names is their admission number.
(iv) To count the number of students who play cricket.
33. Consider the following tables STORE and SUPPLIERS and answer (a)
and (b) parts ofthis question:
Table: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener Classic 23 60 8 31-Jun-09
2003 Ball Pen 0.25 22 50 25 01-Feb-10
2002 Gel Pen Premium 21 150 12 24-Feb-10
2006 Gel Pen Classic 21 250 20 11-Mar-09
2001 Eraser Small 22 220 6 19-Jan-09
2004 Eraser Big 22 110 8 02-Dec-09
2009 Ball Pen 0.5 21 180 18 03-Nov-09
Table: SUPPLIERS
Scode Sname
21 Premium Stationers
23 Soft Plastics
22 Tetra Supply
Write SQL commands for the following statements:
i. To display details of all the items in the STORE table in descending order ofRate.
ii. To display ItemNo and Item name of those items from STORE table whose Rateis
more than 20 Rupees.
iii. To display the details of those items whose supplier code (Scode) is 21
orQuantity in Store (Qty) is more than 110 from the table Store.
iv. To display maximum Rate of items for each supplier individually as per itemfrom
the table STORE.
34. Sameera maintains a database named STORE which contains a table named
ITEM with the structure given below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Help her to remove the record from the table ITEM for a particular value of item
name input by the user
35. Consider the table, MOVIEDETAILS given below:
Table: MOVIEDETAILS
MOVIEID TITLE LANGUAGE RATING PLATFORM
M001Minari Korean 5 Netflix
M004MGR Magan Tamil 4 Hotstar
M010Kaagaz Hindi 3 Zee5
M015Uri Hindi 5 Zee5
(a) Identify the degree and cardinality of the table.
(b) Which field should be made the primary key? Justify your answer.
(c) Identify the candidate key(s) from the table MOVIEDETAILS.
(d) Consider the table SCHEDULE given below:
Table: SCHEDULE
SLOTID MOVIEID TIMESLOT
S001 M010 10 AM to 12 PM
S002 M020 2 PM to 5 PM
S003 M010 6 PM to 8 PM
S004 M011 9 PM to 11 PM
Which field will be considered as the foreign key if the tables MOVIEDETAILS and
SCHEDULE are related in a database?
SECTION E
(5X5=25)
36. MySQL database named WarehouseDB has a product_inventory table in
MySQL which
contains the following attributes:
• Item_code: Item code (Integer)
• Product_name: Name of product (String)
• Quantity: Quantity of product (Integer)
• Cost: Cost of product (Integer)
Consider the following details to establish Python-MySQL connectivity:
• Username: admin_user
• Password: warehouse2024
• Host: localhost
Write a Python program to update the Quantity of the product to 91 whose
Item_code is 1018 and cost is more than 500 in the product_inventory table.
37. A table, named STATIONERY, in ITEMDB database, has the following
structure:
Field Type
itemNo int(11)
itemName varchar(15)
price float
qty int(11)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table
STATIONERY. The function should then retrieve and display all records
from the STATIONERY table where the Price is lesser than equal to 120.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: Pencil
********