Unit Test I - Cs Answer Key
Unit Test I - Cs Answer Key
GENERAL INSTRUCTIONS
• All questions are compulsory.
• Read all the questions carefully.
• Date, page numbers, your name should be there in all the pages of your answer sheets
• It is mandatory that after completing your test, you have to scan your answer sheets and convert
it into pdf and upload it by clicking the appropriate button.
• Arrange all the answer sheets based on the page number, then convert it into pdf.
Page 1 of 7
Answer:
• Upto 2 decimal places. (i.e. expected result 34567.78)
• Upto -3 places(i.e. expected result 34000)
5. Which clause is used to search for NULL values in any column? 1
a) NULL
b) IS NULL
c) EMPTY
d) NULL VALUES
6. A table TRAIN has 4 rows and 2 columns and another table BUS has 3 rows and 4 columns. 1
How many rows and columns will be there if we obtain the Cartesian product of these two
tables?
a) 6 rows 7 columns
b) 7 rows 8 columns
c) 16 rows 6 columns
d) 12 rows 6 columns
7. Evaluate the SQL statement: 1
SELECT ROUND (TRUNCATE (MOD (1600, 10), -1), 2) FROM dual;
What will be displayed?
a) 0
b) 1
c) 00
d) An error statement
Answer: A
Explanation: This statement will give the result 0. A function MOD(1600, 10) returns 0 by calculating
the modulus of 1600 when 1600 is divided by 10 until no further whole number can be produced.
TRUNCATE(x, y) function truncates x to the decimal precision of y. Finally, the ROUND(x, y) function
rounds x to the decimal precision of y. Hence option A is the correct choice.
8. Statement A: Select count( * ) from student; → return 5 1
Statement B: Select count(fee) from student; → return 4
Page 2 of 7
9. Which of the following query contains an error? 1
a) Select * from emp where empid=100;
b) Select empid from emp where empid = 101;
c) Select empid from emp;
d) Select empid where empid=100 and name=’Tom’;
10. Identify the DDL and DML commands from the following. 1
a) Drop → DDL
b) Insert → DML
c) Alter → DDL
d) Delete → DML
Ans. Create table Bank(Acc_number Integer(4) Primary Key, Name Varchar(3) Not
Null, DOB Date, Price Decimal(8,2));
Page 3 of 7
13. Identify the errors in the following query 2
a) Select max(salary) from employee group by designation where DOJ > “2020-02-02”;
Ans. Select max(salary) from employee group by designation having DOJ > “2020-02-02”;
b) Select * from employee where name = “A%”;
Ans. Select * from employee where name like “A%”;
c) Select item from employee where Dept=”Salary” sort by name;
Ans. Select item from employee where Dept=”Salary” order by name;
d) Select name, subject, stipend*12 alias “Annual Stipend” from Exam;
Ans. Select name, subject, stipend*12 as “Annual Stipend” from Exam;
Ans.
a) 5
b) 218
c) 17
d) 1090
Page 4 of 7
Table: EXAM
Adno Sname Percentage Class_sec Stream
R001 Sushil 90.2 12A Science
R002 Vidya 80.5 12C Humanities
R003 Anand 68.9 12B Science
R004 Neha 96.0 12D Commerce
R005 Shalini 88.6 12D Commerce
a) To display ICode, IName and VName of all the Vendors, who manufacture “Refrigerator”.
b) To display IName, ICode, VName and Price of all the products whose price is more than
20000.
c) To display vendor names and names of all items manufactured by vendor whose code is
“P03”.
Answer.
a) Select ICode, IName, VName from Supply S, Vendor V
Where S.Vcode= V.Vcode and IName=”Refrigerator”
b) Select ICode,IName, VName, Price from Supply S, Vendor V where S.VCode =
V.VCode and Price>20000;
c) Select VName, IName from Supply S, Vendor V
Where S.VCode = V.VCode and VCode = ‘P03’;
Page 5 of 7
Q 4. Answer the following Case Study Based Question: (4 x 1 = 4 Marks)
18. Case Study Questions.There are 5 case – based subparts. An examinee is to attempt any 4 out 4
of the 5 subparts.
A departmental store Mystore is considering to maintain their inventory using SQL to store
the data. As a database administer, Ajay has decided that:
Name of the database – Mystore
Name of the table – STORE
The attributes of STORE are as follows:
• ItemNo – numeric
• ItemName – character of size 20
• Scode – numeric
• Quantity – numeric
Table – STORE
ItemNo ItemName Scode Quantity
2005 Pencil 23 60
2006 Ball Pen 22 50
2003 Eraser 21 150
2002 Colour Pencil 21 250
2001 Sketch Pen 22 220
2004 Stickers 22 110
2009 Geomentry Box 21 180
c) Insert the following data into the attributes ItemNo, ItemName and Scode
Respectively in the give table STORE. ItemNo = 2010, ItemName = “NoteBook” and
Scode=25
Ans.
Insert into STORE(itemNo,ItemNaame,Scode) values(2010,”NoteBook”,25);
d) Ajay wants to remove the table STORE from the database MyStore. Which command
will he use from the following:
a) Delete from store;
b) Drop table store;
c) Drop database mystore;
d) Delete store from mystore;
e) Now Ajay wants to display the structure of the table STORE i.e. name of the attibutes
and their respective data types that he has used in the table. Write the query to display
the same.
Ans. Describe Store;/Desc Store;
Page 6 of 7
Q 5. Answer the following question: (5 x 1 = 5 Marks)
19. Consider the following tables FACULTY AND COURSES . Write SQL commands for the 5
statements (i) to (v):
FACULTY:
F_ID FNAME LNAME HIRE_DATE SALARY
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-05-2001 14000
105 Rashmi Malhotra 11-09-2004 11000
106 Sulekha Srivastava 5-6-2006 10000
COURSES:
C_ID F_ID CNAME FEES
C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
a) To display details of those Faculties whose salary is greater than 12000.
b) To display the details of courses whose fees is in the range of 15000 to 50000(both
values included).
c) To increase the fees of all courses by 500 of “System Design” Course.
d) To display details of those courses which are taught by ‘Sulekha’ in descending order
of courses.
e) To display the total fees paid course-wise.
Answer:
a) Select * from Faculty where Salary>12000;
b) Select * from Courses where Fees between 15000 AND 50000;
c) Update Courses set Fees = Fees + 500 where CNAME = “System Design”;
d) Select * from Faculty fac, Courses cour
where fac.F_ID = cour.F_ID AND fac.FNAME=’Sulekha’
ORDER BY CNAME DESC;
e) Select sum (FEES) from courses group by CNAME;
******************************
********* ******* **
Page 7 of 7