You are on page 1of 4

DELHI PUBLIC SCHOOL BANGALORE - EAST

COMPUTER SCIENCE
REVISION WORKSHEET FOR UNIT TEST 2

NAME:_________________ CLASS: XII SEC:_____ DATE: ___________

1) Observe the following table and answer the question (i) , (ii) and (iii)

TABLE: VISITOR

VisitiorID VisitorName ContactNumber


V001 ANAND 9898989898
V002 AMIT 9797979797
V003 SHYAM 9696969696
V004 MOHAN 9595959595

(i) Write the name of most appropriate columns which can be considered as
Candidate keys
(ii) Out of selected candidate keys, which one will be the best to choose
as Primary Key?
(iii) What is the degree and cardinality of the table?

2) Define the below relational terms:


a. Tuple
b. Attribute
c. Relation
d. Domain

3) RDBMS is a collection of:


a. Fields
b. Tables
c. Columns
d. Keys

4) The term attribute refers to of a table:


a. Record
b. Key
c. Tuple
d. Column

5) In RDBMS referential integrity can be specified with the help of ____________


a. Primary Key
b. Secondary Key
c. Foreign Key
d. None of these

6) Table T1 contains 10 Rows and 4 Columns; Table T2 contains 20 Rows and 3


Columns. After performing Cartesian product of T1 and T2, what will be the degree
and cardinality of Resultant output?
7) Based on the given table “SALE” answer the question (i) and (ii)

PRODI QTY RATE AMOUN


D T
1 10 100 1000
2 5 50 250
3 10 20 200
4 20 100 2000
(i) Can we take QTY column of the above table as Primary Key? If no give
reason
(ii) Which column is best suitable for applying Primary Key?

8) Mention any two differences between Single_row functions and Aggregate functions

9)
Write the name of the functions to perform the following operations:
(i) To display the day like “Monday”, “Tuesday” from the date when India got
independence.
(ii) To display the specified number of characters from a particular position of the
given string.
(iii) To display the name of the month in which you were born.
(iv) To display your name in capital letters.

10) Write the output produced by the following SQL commands:


(i) SELECT POW(2,3);
(ii) SELECT ROUND(123.2345, 2), ROUND(342.9234,-1);
(iii) SELECT LENGTH(“Informatics Practices”);
(iv) SELECT YEAR(“1979/11/26”), MONTH(“1979/11/26”), DAY(“1979/11/26”),
MONTHNAME(“1979/11/26”);
(v) SELECT LEFT(“INDIA”,3), RIGHT(“Computer Science”,4);
(vi) SELECT MID(“Mathematics”,3,4), SUBSTR(“Examination”,3);

11) Consider the following table named “Product”, showing details of products being sold in a
grocery shop.

Pcode PName UPrice Manufacture


P01 Washing Powder 120 Surf
P02 Tooth Paste 54 Colgate
P03 Soap 25 Lux
P04 Tooth Paste 65 Pepsodent
P05 Soap 38 Dove
P06 Shampoo 245 Dove
Write SQL queries for the following:
(i) Create the table Product with appropriate data types and constraints.
(ii) Identify the primary key in Product.
(iii) 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.
(iv) Add a new column Discount to the table Product.
(v) 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.
(vi) Increase the price by 12 per cent for all the products manufactured by Dove.
(vii) 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:
(viii) SELECT PName, Average(UPrice) FROM Product GROUP BY Pname;
(ix) SELECT DISTINCT Manufacturer FROM Product;
(x) SELECT COUNT(DISTINCT PName) FROM Notes Product;
(xi) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;

12)

(i) Identify Primary Key from both the tables


(ii) Identify the foreign key column in the table EMP
(iii) Can we delete the record of PETER from table JOB? If not give reason
(iv) Write a query to display EmpNo, EName and DName of all employees from location “admin’
(v) Write a query to display employee details along with their department name and location.
(vi) Write the output of the below query:
SELECT EMP.*, DHEAD FROM EMP E, JOB J WHERE E.DEPTNO = D.DEPTNO
AND DHEAD > 3000
13) Write the python program that connects to the relation School_Bus and executes the following
SQL queries:

Rtno Area_Covered Capacity Noofstud Dist (km) Transporter Charges


1 Vasant Nagar 100 120 10 Anand Travels 25000
2 Rohini Apt 90 80 10 Yadav Co 20000
3 Krishna Apt 100 105 35 Yadav Co 30000
4 Vasant Vihar 50 40 15 Anand Travels 23000

(i) Count the total number of students travelling in Yadav Co.


(ii) Increase the Charges by 2500 where the distance is 30 Km and above.
(iii) To show transporter wise total no of students traveling.
(iv) To insert a new record with the below details :

5 Yamuna Tower 60 55 30 Anand Travels 28000

(v) Delete all buses from Vasant Vihar area

You might also like