Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Test 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Database Test 1

Number of Questions: 35 Section Marks: 30

Directions for questions 1 to 35: Select the correct alterna- 6. Consider the following table:
tive from the given choices. Sailor
Questions 1 to 15 carry one mark each: Sname Rating Age
1. Consider the given ER-Diagram Yashu 9 35
Lalit 10 45
Faculty Meeting Yashu 9 40
Bose 8 41

The given ER-Diagram represents How many tuples are returned by following expression,
(A) Unary Relationship (B) Binary Relationship pSname, Rating (Sailor)
(C) Ternary Relationship (D) None of the above (A) 4 (B) 3
(C) 2 (D) 1
2. Consider the given ER-Diagram:
7. Which of the following statement is FALSE, for 2
Since Pname Relations R and S?
Wld Name Pld (A) RXS returns a Relation with all the fields of R in the
Budget same order as they appear in R followed by all the
fields of S in the same order as they appear in S.
Worker Works Project (B) The fields in RXS have the same domains as the
corresponding fields in R and S.
(C) R ∩ S = R – (R – S)
Which of the following is the descriptive Attribute? (D) R ∩ S = S – (S – R)
(A) WId (B) Since 8. Which of the following correctly describes “Prime
(C) PId (D) {WId, PId} Attribute”?
3. Which of the following statements is FALSE about (A) It should be a part of primary key
“Weak Entity”? (B) It should be a part of any candidate key
(A) A weak entity can be identified uniquely only by (C) It should be a part of every candidate key
considering some of its attributes in conjunction (D) None of the above.
with the primary key of another Entity. 9. Let X, Y and Z denote sets of attributes over a relation
(B) The owner entity set and the Weak entity set must schema R. Match the following.
participate in a one-to-many relationship set. I. If X → Y, then XZ → YZ for any Z
(C) One owner entity is associated with one or more II. If X ⊇ Y, then X → Y
weak entities, but each weak entity has a single III. If X → YZ, then X → Y and X → Z
owner. P. Reflexivity
(D) The weak entity set may/may not have total par- Q. Augmentation
ticipation in the identifying relationship set. R. Decomposition
(A) I–Q, II–P, III–R (B) I–P, II–R, III–Q
4. Consider the given Relation schema: (C) I–P, II–Q, III–R (D) I–R, II–Q, III–P
Student (RNo: integer, sname: string, login: string, age:
10. Which of the following are additional features of SQL?
integer, grade: char(1), parent-name: string, percent-
(A) SQL has language constructs for specifying views,
age: Real).
also known as virtual tables, using the CREATE
What is the “Arity” of given Relation schema?
VIEW Statement
(A) 2, 3, 1, 1 (B) 7 (B) SQL and Relational databases can interact with
(C) 3, 4 (D) 6 new technologies such as XML and OLAP.
5. Which of the following specifies “Cardinality” of a (C) SQL has Language constructs for creating triggers
Relation? (D) All the above
(A) The number of fields in a Relation 11. Consider the given Functional Dependencies for
(B) The number of columns in a Relation Employee – Project Relation:
(C) The number of Tuples in a Relation ENo → EName
(D) Both (A) and (C) PNo → PName, Location
3.112 | Database Test 1

{ENo, PNo} → Hours To Rename table as Employee or WId as EId, service as


How many attributes appear in the closure of ENo, Experience, which of the following is not valid?
(ENo+)? (A) ρEmployee worker
(A) 1 (B) 2 (B) ρ(EID, Experience) worker
(C) 3 (D) 5 (C) ρ(EID, Name, Experience, Age) worker
12. Magnetic tapes are sequential access devices, to access (D) ρEmployee (EID, Name, Experience, Age) worker
the nth block on tape _____? 18. Consider the given schema for sailors
(A) We must scan over the preceding (n – 1) blocks sailors(Sid : integer, Sname : string, Rating : integer,
(B) We can scan directly nth block age : real).
n Which of the following SQL Queries is invalid?
(C) We must scan atleast blocks before scanning
th 2 (A) SELECT S.Rating, (S.age)
n block
n FROM Sailors S
(D) We must scan atmost blocks before scanning WHERE S.Rating = 10
th
n block 2
(B) SELECT S.Rating, MAX (S.age)
13. What is the unused space in each block, for fixed length FROM Sailors S
record of size ‘R’ bytes with B ≥ R (B = Block Size), we GROUPBY S.Rating
can fit B/R (bfr = B/R) records in one block? (C) SELECT S.Sname, MAX (S.age)
(A) B – (bfr * R) (B) (B – bfr * R) + 1 FROM Sailors S
B WHERE S.Rating > 7
(C) B + (bfr * R) (D) +R (D) SELECT AVG (S.Age)
bfr
FROM Sailors S
14. To utilize the unused space in each block, we can store WHERE S.Rating > 8
part of a record on one block and the rest on another, 19. Consider the schema given in the above Question,
A pointer at the end of the first block points to the SELECT Sname
block containing the remaining part of record, what this FROM Sailors
organization is called? WHERE Rating IN(6, 8, 9, 10)
(A) Unspanned (B) Spanned What is retrieved by the above query?
(C) Distributed (D) Collabarative (A) The names of sailors whose Rating is between 6
15. For variable length records using spanned organization, and 10.
each block may store different number of records. The (B) The names of sailors whose Rating is any one of 6,
blocking factor “bfr” represents the average number of 8, 9, 10.
records per block for the file, what is the number of (C) Both (A) and (B)
blocks ‘b’ needed for a file of ‘r’ records? (D) None of the above
 r 
(A) b = 
bfr  20. Let ‘R’ be a Relation schema and Let x and y be non
 (B) b =  
 r   bfr  empty sets of attributes in R. An instance ‘r’ of R satis-
fies the FD –x → y. For which of the following tuples
2 × r 
(C) b =  r × bfr  (D) b =   t1 and t2 are in r?
 bfr  (A) t1 ⋅ x = t2 ⋅ x and t1 ⋅ y = t2 ⋅ y
16. Which of the following SQL Query is valid to increment (B) t1 ⋅ x = t2 ⋅ y and t1 ⋅ y = t2 ⋅ y
the age of the student whose student Id (Sid) is 63078? (C) t1 ⋅ x = t2 ⋅ x and t1 ⋅ y = t2 ⋅ x
(A) Update student S (D) t1 ⋅ x = t2 ⋅ y and t1 ⋅ x = t2 ⋅ y
SET S.age = S.age + 1; 21. Consider the following Relational instance?
WHERE S.Sid = 63078
(B) Select S.age + 1 A B C D
From student S a1 b1 c1 d1
Where S.Sid = 63078 a1 b1 c1 d2
(C) Update S.age = S.age + 1
a3 b2 c3 d1
WHERE S.Sid = 63078
(D) Both (A) and (B) a2 b3 c2 d4

17. Consider the given Relation worker


Worker Which of the following are satisfied by the given in-
stance?
WId Name Service Age (A) AB → C (B) AB → CD
(C) AC → D (D) D → AC
Database Test 1 | 3.113

22. Consider the given Relation R (C) Select *


R From Employee, Department
W X Z (D) Select *
W1 X1 Z1 From (Employee JOIN Department IN Employee.
DNo = Department.DNo)
W2 X2 Z2
W3 X2 Z1
27. Consider the given Functional Dependencies for
Employee – project Relation
pwx(R) x pxz(R), what is the number of tuples returned ENo → EName
by the given expression? PNo → PName, Location
(A) 2 (B) 3 {ENo, PNo} → Hours
(C) 4 (D) 5 How many attributes are included in the closure of
23. For the Relation ‘R’ given in the above question, if we {ENo, PNo}+?
perform pwx (R) pxz (R) ( : left outer join), what is (A) 2 (B) 4
the number of tuples that appear in the Result? (C) 5 (D) 6
(A) 0 (B) 3 Common data for Questions 28 and 29:
(C) 5 (D) 6 Consider the 2 tables T1 and T2
24. Consider the given SQL Query: Table T1
Select DISTINCT ENo
P Q R
From works
Where (PNo, Hours) IN (Select PNo, Hours 20 X 50
From works where ENo = ‘788’); 25 Y 80
What is returned by the above query? 35 X 60
(A) The employee numbers of all employees who work Table T2
on the same (PNo, Hours) combination on some
project on which Employee ENo 788 is working. A B C
(B) The employee numbers of all employees who 20 Y 60
work on the same (PNo, Hours) combination 35 Z 30
whose ENo is 788. 20 Y 50
(C) Both (A) and (B)
(D) None of the above 28. What is the number of tuples returned from
25. Retrieve the Employee numbers (ENo) of all employ- T1  (T1 ⋅ P = T2 ⋅ A AND T1 ⋅ R = T2 ⋅ C)T2?
ees who work on project numbers 11, 22, 23, 24? (A) 0 (B) 1
(A) SELECT ENo (C) 2 (D) 3
FROM Works 29. What is the number of tuples returned from
Where PNo IN(11, 22, 23, 24)
T1  (T1 ⋅ P = T2 ⋅ A OR T1 ⋅ R = T2 ⋅ C) T2?
(B) Select DISTINCT ENo
(A) 1 (B) 2
From Works
(C) 3 (D) 4
Where PNo IN(11, 22, 23, 24)
(C) Select ENo Common data for Questions 30 and 31:
FROM Works Consider the given Relation worker:
Where PNo = 11 AND PNo = 22 AND PNo = 23 Name Age Project-Number
AND PNo = 24.
Anu 26 10
(D) Select *
Bala 24 20
FROM works
Where PNo = 11 OR PNo = 22 OR PNo = 23 OR Sudhir 28 10
PNo = 24. Shreya 24 10

26. Which of the following correctly specifies the “JOIN” Bharat 19 20


Operation on 2 tables Employee and Department, the Srinath 21 30
common field in both tables is DNo? Raj 22 30
(A) Select * Mishra 21 20
From (Employee JOIN Department ON Employ- Phani 19 40
ee.DNo = Department.DNo)
(B) Select * 30. What is the Result of the following SQL Query
From (Employee JOIN Department) SELECT Project-Number, MIN (Age)
3.114 | Database Test 1

FROM Worker 32. Which of the following Tuple is not part of sailor-1 and
GROUPBY Project-Number sailor-2?
HAVING COUNT (*) ≥ 3 (A)
(A) Yashu 9 35 Kamal 10 41
Project-Number MIN (Age) (B)
10 24 Lalit 10 45 Raj 10 40
20 19 (C)
(B) Ana 7 40 Kamal 7 40
Project-Number MIN (Age) (D)
10 24 Bose 8 41 Lalit 10 45

20 19 33. What is the number of tuples appear in sailor-1 SET


30 21 DIFFERENCE sailor-2?
40 19
(A) 0 (B) 1
(C) 2 (D) 3
(C)
Common Data for Questions 34 and 35:
Project-Number MIN (Age)
Consider the given 2 tables Employee and Department and
10 24 primary keys are shown with underline.
20 19
Employee
30 21
EId Name DNo Age
(D)
0326 Kumar 5 38
Project-Number MIN (Age)
0429 Nilesh 4 36
20 19
0589 Phani 4 34
40 19
0679 Raja 3 36
31. In the Result of following SQL query 0588 Deepak 2 37
SELECT Age, count (*) Department
FROM Worker
GROUPBY Age DNo DName
What is the number of tuples? 1 Accounts
(A) 4 (B) 5 2 Sales
(C) 6 (D) 9 3 Marketing
Common data for Questions 32 and 33: 4 Executives
Consider the given 2 tables: 5 Research
Sailor-1:
Sname Rating Age 34. Insert into Employee values < 0589, ‘Anurag’, 3, 37 >,
Yashu 9 35
The above operation violates which constraint?
(A) NOT NULL Constraint
Lalit 10 45
(B) KEY Constraint
Bose 8 41
(C) Entity Integrity Constraint
Ana 7 40 (D) Referential Integrity Constraint
Sailor-2 35. Delete Department tuple with DNo = 5, The above
Sname Rating Age operation violates which constraint?
Raj 10 40 (A) NOT NULL Constraint
Kamal 10 41 (B) KEY Constraint
Ana 7 40
(C) Referential Integrity Constraint
(D) Entity Integrity Constraint

Answer Keys
1. A 2. B 3. D 4. B 5. C 6. B 7. D 8. B 9. A 10. D
11. B 12. A 13. A 14. B 15. B 16. D 17. B 18. C 19. B 20. A
21. A 22. D 23. C 24. A 25. B 26. A 27. D 28. B 29. D 30. A
31. C 32. D 33. D 34. B 35. C
Database Test 1 | 3.115

Hints and Explanations


1. If only one entity is participating in a relationship that 17. ρ(EID, Experience) worker
relation is called Unary Relation. Choice (A) It will replace WID with EID and Name with Experi-
2. Descriptive attributes are used to record information ence which is NOT Valid. Choice (B)
about the relationship, rather than about any one of the 18. If select clause uses an aggregate operation, then it
participating entities. Suppose we wish to record that a must only use aggregate unless the query contains a
particular worker is working for a project since 1993; GROUP BY clause. Choice (C)
This information is captured by adding an attribute 19. It retrieves the names of sailors whose Rating is any
“since” to works. Choice (B) one of the given Ratings 6, 8, 9, 10.
3. The weak entity set must have total participation in the Choice (B)
identifying relationship set. Choice (D)
20. t1 ⋅ x = t2 ⋅ x and t1 ⋅ y = t2 ⋅ y. Choice (A)
4. The degree is also called “Arity” of a relation, is the
21. The given instance satisfies AB → C.
number of fields (or) columns, There are ‘7’ fields.
Choice (B) Choice (A)
5. The “cardinality” of a relation instance is the number of 22. pwx (R)
tuples in it. The degree of the relation is the number of W X
fields (or) columns. Choice (C) W1 X1
6. p-project, eliminates duplicates W2 X2
W3 X2
Sname Rating
pXZ (R)
Yashu 9
Lalit 10 X Z
Bose 8 X1 Z1
X2 Z2
∴ Hence ‘3’ tuples. Choice (B)
X2 Z1
7. R ∪ S = S – (S – R) is not TRUE. Choice (D)
8. Prime Attributes should be part of any candidate key. pwx (R) () pxz (R)
Choice (B)
W X Z
9. Choice (A) W1 X1 Z1
10. All the statements are additional features of SQL. W2 X2 Z2
Choice (D) W2 X2 Z1
11. ENo+ = {ENo, EName}. Choice (B) W3 X2 Z2

12. We must scan over the preceding (n – 1) blocks. W3 X2 Z1


Choice (A) Choice (D)
13. B – (bfr * R) is the unused space in each block. 23. All tuples in pwx (R) has atleast one matching in pxz (R),
Choice (A) so same number of tuples as pwx  pxz (R), returned in
14. It is called spanned organization. Choice (B) the result. Choice (C)

 r  24. The employee numbers of all employees who work on


15. b =    Choice (B) the same (PNO, Hours) combination on some project
  bfr   on which employee ENO 788 is working. Choice (A)
16. We can modify the column values in an existing row 25. Some employees may work on more than one project,
using the UPDATE command. We can increment the so DISTINCT Key word will eliminate duplicates in
age of the student with Sid 63078 the output. Choice (B)
UPDATE Student S
26. The concept of Joining Relations was incorporated into
SET S.age = S.age + 1
SQL to permit users to specify a table resulting from a
WHERE S.Sid = 63078 Join operation in the FROM clause of a query.
(or)
Choice (A)
Select S.age + 1
From Student S 27. {ENo, PNo}+ = {ENo, PNo, EName, PName, Location,
Where S.Sid = 63078. Choice (D) Hours}. Choice (D)
3.116 | Database Test 1

28. T1  T2 Table-4

P Q R A B C Name Age Project-Number


20 X 50 20 Y 60 Phani 19 40
20 X 50 35 Z 30
20 X 50 20 Y 50 Table-1 and Table-2 are satisfying the condition count
(*) ≥ 3. Choice (A)
25 Y 80 20 Y 60
25 Y 80 35 Z 30 31. GROUP-BY Age returns
25 Y 80 20 Y 50
Anu 26 Sudhir 28
35 X 60 20 Y 60
35 X 60 35 Z 30 Bala 24 Bharat 19
35 X 60 20 Y 50
Shreya 24 Phani 19
rd
Only 1(3 tuple). Choice (B) Srinath 21
29. Refer the table given in the above solution. Mishra 21 Raj 21
T1 ⋅ P = T2 ⋅ A
Result:
1st, 3rd, 8th tuples
T1 ⋅ R = T2 ⋅ C Age Count (*)
7th tuple 19 2
∴ Total ‘4’ tuples. Choice (D) 21 2
30. GROUP-BY Project-Number gives 22 1
Table-1 24 2
26 1
Name Age Project-Number
28 1
Anu 26 10
Sudhir 28 10 Choice (C)
Shreya 24 10 32. The tuple Bose 8 41 cannot have cross product
with any tuple in sailor-1. Choice (D)
Table-2
33. It returns the tuples that are present in sailor-1 but not
Name Age Project-Number
in sailor-2, Ana 7 40 is present in sailor-1 and
Bala 24 20
sailor-2 also, so this will not appear in the Result of
Bharat 19 20
sailor-1 SET DIFFERENCE sailor-2. Choice (D)
Mishra 21 20
34. It violates KEY constraint, because EID is primary key
Table-3 and EID 0589 is already present in the employee table.
Choice (B)
Name Age Project-Number 35. Employee table references to Department table,
Srinath 21 30 Absence of DNo = 5 causes Referential Integrity
Raj 22 30 Constraint violation. Choice (C)

You might also like