Computer Science Practice Questions-3, Database Concepts
Computer Science Practice Questions-3, Database Concepts
Practice Questions
Topic: Database Concepts
Full Marks 20
NOTE
• You are advised against doing selective study. D{8] is the element of the dictionary w
• The questions given above are sample questions for practice prior to Board Examination.
• Although Answer Keys will be provided within 2-3 days of posting of these questions, you are
advised to answer them yourself.
• In case you have queries regarding a portion of the chapters being revised here you may send
your query to your teacher through Chat section in MS Teams.
1. A relation in a database: 1
a) Can store only primary keys
b) Can be used to store data for a single instance of data only
c) Can store data for different instances of a given entity
d) Can be used to store data for a given property of an entity instance
2. The domain of 4 character model number values for an electronic product starting with either U, E, or
A and ending with either M, K, D, W can include: 1
a) E57A, U19W, Y47D, U05K
b) U20D, E38M, U65W, A24D
c) K15D, E18K, U65F, A14D
d) W11U, K48E, D15E, M55U
3. The attributes represent: 1
a) The values used to make the primary key of a relation
b) The data regarding a given entity
c) The different entity instances of a given entity
d) The different properties of a given entity
4. The cardinality of a relation in a DBMS: 1
a) Indicates the number of tuples in the relation
b) Indicates the number of cells in the relation
c) Indicates the number of columns in the relation
d) Indicates the number of candidate keys in the relation
5. Consider the table PARTS(Part#, Barcode#, Category, Warehouse#, Shelf#, Box#, Price). The probable
set of candidate keys can be: 1
a) [Barcode#], [Category, Warehouse#], [Warehouse#, Price]
b) [Category], [Barcode#], [Price]
c) [Category, Price], [Barcode#], [Warehouse#, Shelf#, Box#]
d) [Part#], [Barcode#], [Warehouse#, Shelf#, Box#]
6. Which of the following is not applicable for a foreign key? 1
a) Values can repeat under the foreign key column.
b) It is the primary key of another table.
c) It can be a part of the primary key of the table where it is the foreign key.
d) Values should be unique under the foreign key column.
7. Write the code to create a table with the following structure: 3
Name of table DELIVERY
Attribute name Shipment# char(4) Primary Key
Attribute name BookingDate date
Attribute name Weight decimal(6,2)
Attribute name Address varchar(50)
Attribute name DeliveryDate date
8. A table called FRIENDS (Serial#, FName, LName, Address, Phone, Email) has initially data for 17 friends.
Later two more attributes were added to the table. Data for 5 new friends were added to the table
and one friend passed away and his data was removed from the table. ½x4=2
a) What is the degree of the modified table?
b) What is the cardinality of the modified table?
c) Suggest a primary key for the table.
d) Suggest the candidate keys for the FRIENDS table.
9. State the difference between the WHERE and the HAVING clause with the help of an example. 2
10. Find the output of the following queries in SQL: ½x8=4
FACTORY DEPARTMENT
EmpID FName LName Gender Age DepID Branch Salary DepID Name Strength
12 AJIT ADDHYA M 52 D3 Kolkata 50000 D1 Sales 15
14 SUMON SEN M 26 D2 Maldah 28000 D2 Purchase 10
18 BIJON BERA M 50 D5 Asansol 80000 D3 HR 8
21 REHANA RAY F 48 D2 Howrah 60000 D4 Accounts 19
35 RAHUL RAI M 36 D4 Howrah 50000 D5 Security 12
39 ELA EHSAN F 28 D4 Kolkata 46000
42 ARSHAD ALI M 56 D1 Maldah 28000
51 RAJA RAHEJA M 32 D5 Kolkata 50000
53 KAYA KHAN F 45 D3 Howrah 60000
61 SNEHAL SHAH F 32 D3 Asansol 30000
65 REKHA RAJ F 50 D2 Kolkata 45000
72 ARHITA ADAK F 48 D1 Kolkata 55000
88 RIA ROBIN F 50 D4 Maldah 60000
a) select fname, lname from factory where gender = ‘F’ and deptid = ‘D4’;
b) select empid, gender, from factory where deptid in (‘D1’ , ‘D3’) and Branch = ‘Kolkata’;
c) select fname, age, from factory where fname like ‘R_ _ _ %A’;
d) select fname, lname, gender from factory where branch = ‘Maldah’ order by fname;
e) select branch, count(*) from factory group by branch having count(*) > 2;
f) select branch, gender, avg(age) from factory group by branch, gender;
g) select fname, name from factory F, department D where F.deptid = D.deptid and gender = ‘F’;
h) select fname, salary from factory F, department D where F.deptid = D.deptid and deptid = ‘D3’;