DBMSNotes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

DBMS

1. In the context of owner and weak entity sets in the ER (Entity-Relationship) data model, which one of the
following statements is TRUE?
A. The weak entity set MUST have total participation in the identifying relationship
B. The owner entity set MUST have total participation in the identifying relationship
C. Both weak and owner entity sets MUST have total participation in the identifying relationship
D. Neither weak entity set nor owner entity set MUST have total participation in the identifying
relationship

2. Let S be the specification: "Instructors teach courses. Students register for courses. Courses are allocated
classrooms. Instructors guide students." Which one of the following ER diagrams CORRECTLY
represents S?

A. (i)
B. (ii)
C. (iii)
D. (iv)

3. Which symbol denote derived attributes in ER Model?


A. Double ellipse
B. Dashed ellipse
C. Squared ellipse
D. Ellipse with attribute name underlined

4. Consider the entities 'hotel room', and 'person' with a many to many relationship 'lodging' as shown below:
If we wish to store information about the rent payment to be made by person (s) occupying different
hotel rooms, then this information should appear as an attribute of
A. Person
B. Hotel Room
C. Lodging
D. None of these

5. Given the basic ER and relational models, which of the following is INCORRECT?
A. An attribute of an entity can have more than one value
B. An attribute of an entity can be composite
C. In a row of a relational table, an attribute can have more than one value
D. In a row of a relational table, an attribute can have exactly one value or a NULL value
relational table requires that, in a row, an attribute can have exactly one value or NULL value.

6. Which one of the following is used to represent the supporting many-one relationships of a weak entity set in
an entity-relationship diagram?
A. Diamonds with double/bold border
B. Rectangles with double/bold border
C. Ovals with double/bold border
D. Ovals that contain underlined identifiers

7. In E-R model, Y is the dominant entity and X is subordinate entity


A. If X is deleted, then Y is also deleted
B. If Y is deleted, then X is also deleted
C. If Y is deleted, then X is not deleted
D. None of the above

8. In an Entity-Relationship (ER) model, suppose 𝑅 is a many-to-one relationship from entity set E1 to entity set
E2. Assume that E1 and E2 participate totally in 𝑅 and that the cardinality of E1 is greater than the cardinality
of E2.
Which one of the following is true about 𝑅?
A. Every entity in E1 is associated with exactly one entity in E2
B. Some entity in E1 is associated with more than one entity in E2
C. Every entity in E2 is associated with exactly one entity in E1
D. Every entity in E2 is associated with at most one entity in E1
Since it is a many to one relationship from E1 to E2, therefore:

1. No entity in 𝐸1 can be related to more than one entity in 𝐸2. ( hence B is incorrect)
2. An entity in 𝐸2 can be related to more than one entity in 𝐸1.(hence C and D are incorrect).

9. An ER model of a database consists of entity types 𝐴 and 𝐵. These are connected by a relationship 𝑅 which
does not have its own attribute. Under which one of the following conditions, can the relational table for R be
merged with that of A?
A. Relationship 𝑅 is one-to-many and the participation of 𝐴 in 𝑅 is total
B. Relationship 𝑅 is one-to-many and the participation of 𝐴 in 𝑅 is partial
C. Relationship 𝑅 is many-to-one and the participation of 𝐴 in 𝑅 is total
D. Relationship 𝑅 is many-to-one and the participation of 𝐴 in 𝑅 is partial

10. Consider the following Relationship Entity Diagram (ERP)

Which of the following possible relations will not hold if the above ERD is mapped into a relation model?
A. Person (NID, Name)
B. Qualification (NID, ExamID, QualifiedDate)
C. Exam (ExamID, NID, ExamName)
D. Exam (ExamID, ExamName)

11. An aggregation association is drawn using which symbol?


A. A line which loops back on to the same table
B. A small open diamond at the end of a line connecting two tables
C. A small closed diamond at the end of a line connecting two tables
D. A small closed triangle at the end of a line connecting two tables
12. Which one of the options given below refers to the degree (or arity) of a relation in relational database
systems?
A. Number of attributes of its relation schema.
B. Number of tuples stored in the relation.
C. Number of entries in the relation.
D. Number of distinct domains of its relation schema.
Relational Model Definitions:
A relation is a table with columns and rows.
An attribute is a named column of a relation.
A tuple is a row of a relation.
A domain is a set of allowable values for one or more attributes.
The degree of a relation is the number of attributes it contains.
The cardinality of a relation is the number of tuples it contains.
A relational database is a collection of normalized relations with distinct relation names.
The intension of a relation is the structure of the relation including its domains.
The extension of a relation is the set of tuples currently in the relation.

13. Consider a relation 𝑅(𝐴,𝐵,𝐶,𝐷,𝐸) with the following three functional dependencies.
𝐴𝐵→𝐶;𝐵𝐶→𝐷;𝐶→𝐸;
The number of superkeys in the relation 𝑅 is ______8________ .

(AB)+ = ABCDE  2 independent and 3 attribute keys  2^3  8

14. Consider the following statements 𝑆1 and 𝑆2 about the relational data model:
𝑆1: A relation scheme can have at most one foreign key.
𝑆2: A foreign key in a relation scheme 𝑅 cannot be used to refer to tuples of 𝑅.
Which one of the following choices is correct?
A. Both 𝑆1 and 𝑆2 are true
B. 𝑆1 is true and 𝑆2 is false
C. 𝑆1 is false and 𝑆2 is true
D. Both 𝑆1 and 𝑆2 are false

15. What does a data dictionary will identify?


A. Field name
B. Field format
C. Field types
D. All of the above
A data dictionary is a file or a set of files that contains a database's metadata. The data dictionary
contains records about other objects in the database, such as data ownership, data relationships to other
objects, and other data.
16. Considering the following table in a relational database :

Last Name Rank Room shift


Smith Manager 234 Morning
Jones Custodian 33 Afternoon
Smith Custodian 33 Evening
Doe Clerical 222 Morning

According to the data shown in the table, which of the following could be a candidate key of the table?
A. {Last Name}
B. {Room}
C. {Shift}
D. {Room, Shift}
Candidate key:- must be able to uniquely determine every other attribute. i.e., whenever a candidate key value is
repeated, all other values must repeat or in a set, candidate key cannot be repeated.

17. Immunity of the external schemas (or application programs) to changes in the conceptual scheme is referred to
as:
A. Physical Data Independence
B. Logical Data Independence
C. Both (a) and (b)
D. None of the above
Physical data independence:- if we make any change in the physical storage of schema that it will not affect our
logical schema/ conceptual schema like relation table.
Logical data independence:- if we make any change in the conceptual schema it will not affect external schema
or end software using this database.

18. Goals for the design of the logical scheme include


A. avoiding data inconsistency
B. being able to construct query easily
C. being able to access data efficiently
D. All of the above

19. Which of the following is NOT a superkey in a relational schema with attributes 𝑉,𝑊,𝑋,𝑌,𝑍 and primary key
𝑉 𝑌?
A. 𝑉𝑋𝑌𝑍
B. 𝑉𝑊𝑋𝑍
C. 𝑉𝑊𝑋𝑌
D. 𝑉𝑊𝑋𝑌𝑍
the primary key is {V,Y} this should be present in all superkey...check in all option in option B ..{V,Y}

20. If D1,D2,…D𝑛 are domains in a relational model, then the relation is a table, which is a subset of
A. D1⊕D2⊕⋯⊕D𝑛
B. D1×D2×⋯×D𝑛
C. D1∪D2∪⋯∪D𝑛
D. D1∩D2∩⋯∩D𝑛

21. Let R = (A, B, C, D, E, F) be a relation scheme with the following dependencies C→F, E→A, EC→D, A→B.
Which of the following is a key of R?
A. CD
B. EC EC is minimal Super key which can derive all the attributes of relation...
C. AE
D. AC
22. The maximum length of an attribute of type text is
A. 127
B. 255
C. 256
D. It is variable Text types are Variable length types

23. Let 𝑥,𝑦,𝑧,𝑎,𝑏,𝑐 be the attributes of an entity set E. If {𝑥},{𝑥,𝑦},{𝑎,𝑏},{𝑎,𝑏,𝑐},{𝑥,𝑦,𝑧} are superkeys then
which of the following are the candidate keys?
A. {𝑥,𝑦} and {𝑎,𝑏}
B. {𝑥} and {𝑎,𝑏}  Minimal superkey Are Also Called Candidate key..
C. {𝑥,𝑦,𝑧} and {𝑎,𝑏,𝑐}
D. {𝑧} and {c}

24. Given an instance of the STUDENTS relation as shown as below:

Student ID Student Name Student Email Student Age CPI


2345 Shankar shankar@math X 9.4
1287 Swati swati@ee 19 9.5
7853 Shankar shankar@cse 19 9.4
9876 Swati swati@mech 18 9.3
8765 Ganesh ganesh@civil 19 8.7

For (Student Name, Student Age) to be a key for this instance, the value X should NOT be equal
to__19____.
Name and Age together form a key,

25. The maximum number of superkeys for the relation schema R(E, F, G, H) with E as the key is _____.
3 keys F,G,H has 2 choices either present in candidate key or not  2^3  8

26. Consider the relation scheme 𝑅=(𝐸,𝐹,𝐺,𝐻,𝐼,𝐽,𝐾,𝐿,𝑀,𝑁) and the set of functional dependencies{{𝐸,𝐹}→{𝐺},
{𝐹}→{𝐼,𝐽},{𝐸,𝐻}→{𝐾,𝐿},{𝐾}→{𝑀},{𝐿}→{𝑁}}on 𝑅. What is the key for 𝑅?
A. {𝐸,𝐹}
B. {𝐸,𝐹,𝐻}
C. {𝐸,𝐹,𝐻,𝐾,𝐿}
D. {𝐸}

27. Consider a relational table with a single record for each registered student with the following attributes:
Registration_Num: Unique registration number for each registered student
UID: Unique identity number, unique at the national level for each citizen
BankAccount_Num: Unique account number at the bank. A student can have multiple accounts or joint
accounts. This attribute stores the primary account number.
Name: Name of the student
Hostel_Room: Room number of the hostel

Which of the following options is INCORRECT?


A. BankAccount_Num is a candidate key
B. Registration_Num can be a primary key
C. UID is a candidate key if all students are from the same country
D. If 𝑆 is a super key such that 𝑆∩UID is NULL then 𝑆∪UID is also a superkey

28. Purpose of 'Foreign Key' in a table is to ensure


A. Null Integrity
B. Referential Integrity
C. Domain Integrity
D. Null and Domain Integrity
29. From the following instance of a relation schema 𝑅(𝐴,𝐵,𝐶), we can conclude that:

A B C
1 1 1
1 1 0
2 3 2
2 3 2

A. 𝐴 functionally determines 𝐵 and 𝐵 functionally determines 𝐶


B. 𝐴 functionally determines 𝐵 and 𝐵 does not functionally determine 𝐶
C. 𝐵 does not functionally determine 𝐶
D. 𝐴 does not functionally determine 𝐵 and 𝐵 does not functionally determine C
Since for this table we can clearly see that everytime when A=1 then B=1 and everytime when A=2 then B=2
so for this particular snapshot we can say that A functionally determines B.
But observing for functional dependency of B and C,
We see that when B=1 then C has two values 1, 0 hence B fails to funtionally determine C.

30. Consider a schema 𝑅(𝐴,𝐵,𝐶,𝐷) and functional dependencies 𝐴→𝐵 and 𝐶→𝐷. Then the decomposition of R
into 𝑅1(𝐴,𝐵) and 𝑅2(𝐶,𝐷) is
A. dependency preserving and lossless join
B. lossless join but not dependency preserving
C. dependency preserving but not lossless join
D. not dependency preserving and not lossless join
Here, no common attribute in R1 and R2, therefore lossy join will be there.and both the dependencies are
preserved in composed relations so, dependency preserving.

31. Consider the following three relations in a relational database.


Employee(eId―,Name),Brand(bId―,bName),Own(eId―,bId―)
Which of the following relational algebra expressions return the set of elds who own all the brands?
A. Π𝑒𝐼𝑑(Π𝑒𝐼𝑑,𝑏𝐼𝑑(𝑂𝑤𝑛)/Π𝑏𝐼𝑑(𝐵𝑟𝑎𝑛𝑑))
B. Π𝑒𝐼𝑑(𝑂𝑤𝑛)–Π𝑒𝐼𝑑((Π𝑒𝐼𝑑(𝑂𝑤𝑛)×Π𝑏𝐼𝑑(𝐵𝑟𝑎𝑛𝑑))–Π𝑒𝐼𝑑,𝑏𝐼𝑑(𝑂𝑤𝑛))
C. Π𝑒𝐼𝑑(Π𝑒𝐼𝑑,𝑏𝐼𝑑(𝑂𝑤𝑛)/Π𝑏𝐼𝑑(𝑂𝑤𝑛))
D. Π𝑒𝐼𝑑((Π𝑒𝐼𝑑(𝑂𝑤𝑛)×Π𝑏𝐼𝑑(𝑂𝑤𝑛))/Π𝑏𝐼𝑑(𝐵𝑟𝑎𝑛𝑑))
𝜋eld, bld (Own) / 𝜋bld (Brand) ⇒ Results eid's which owns every brand of brand relation.

32. What is the optimized version of the relation algebra expression 𝜋𝐴1(𝜋𝐴2(𝜎𝐹1(𝜎𝐹2(𝑟)))), where 𝐴1,𝐴2 are
sets of attributes in 𝑟 with 𝐴1⊂𝐴2 and 𝐹1,𝐹2 are Boolean expressions based on the attributes in 𝑟?
A. 𝜋𝐴1(𝜎(𝐹1∧𝐹2)(𝑟))
B. 𝜋𝐴1(𝜎(𝐹1∨𝐹2)(𝑟))
C. 𝜋𝐴2(𝜎(𝐹1∧𝐹2)(𝑟))
D. 𝜋𝐴2(𝜎(𝐹1∨𝐹2)(𝑟))
since 𝐴1 is subset of 𝐴2 will get only 𝐴1 attributes as it is in the outside, so we can remove project 𝐴2.

33. Which of the following tuple relational calculus expression(s) is/are equivalent to ∀𝑡 ∈ 𝑟(𝑃(𝑡))?
I. ¬∃𝑡∈𝑟(𝑃(𝑡))
II. ∃𝑡∉𝑟(𝑃(𝑡))
III. ¬∃𝑡∈𝑟(¬𝑃(𝑡))
IV. ∃𝑡∉𝑟(¬𝑃(𝑡))
A. I only
B. II only
C. III only
D. III and IV only
The given statement means for all tuples from r, P is true. III means there does not exist a tuple in r where P is not true. Both
are equivalent.

34. Consider the relations 𝑟1(P, Q, R) and 𝑟2(R, S, T) with primary keys P and R respectively. The relation 𝑟1
contains 2000 tuples and 𝑟2 contains 2500 tuples. The maximum size of the join 𝑟1⋈𝑟2 is :
A. 2000
B. 2500
C. 4500
D. 5000
The common attribute is R and it is the primary key in the second relation. So R value should be distinct (primary key
implies unique) for 2500 rows. Hence when we do join, maximum possible number of tuples is 2000.

35. Which of the following relational query languages have the same expressive power?
I. Relational algebra
II. Tuple relational calculus restricted to safe expressions
III. Domain relational calculus restricted to safe expressions
A. II and III only
B. I and II only
C. I and III only
D. I, II and III  All are equivalent in expressive power

36. Let 𝑅1(𝐴, 𝐵, 𝐶) and 𝑅2(𝐷, 𝐸) be two relation schema, where the primary keys are shown underlined, and let C
be a foreign key in 𝑅1 referring to 𝑅2. Suppose there is no violation of the above referential integrity
constraint in the corresponding relation instances 𝑟1 and 𝑟2. Which of the following relational algebra
expressions would necessarily produce an empty relation?
A. Π𝐷(𝑟2) − Π𝐶(𝑟1)
B. Π𝐶(𝑟1) − Π𝐷(𝑟2)
C. Π𝐷(𝑟1⋈𝐶≠𝐷 𝑟2)
D. Π𝐶(𝑟1⋈𝐶=𝐷 𝑟2)
C in 𝑅1 is a foreign key referring to the primary key 𝐷 in 𝑅2. So, every element of 𝐶 must come from
some 𝐷 element.

37. With regards to the expressive power of the formal relational query languages, which of the following
statements is true?
A. Relational algebra is more powerful than relational calculus
B. Relational algebra has the same power as relational calculus
C. Relational algebra has the same power as safe relational calculus
D. None of the above

38. Given the relations


 employee (name, salary, dept-no), and
 department (dept-no, dept-name, address),
Which of the following queries cannot be expressed using the basic relational algebra
operations (𝜎,𝜋,×,⋈,∪,∩,−)?
A. Department address of every employee
B. Employees whose name is the same as their department name
C. The sum of all employees' salaries
D. All employees of a given department

39. Consider the join of a relation 𝑅 with a relation 𝑆. If 𝑅 has 𝑚 tuples and 𝑆 has 𝑛 tuples then the maximum and
minimum sizes of the join respectively are
A. 𝑚+𝑛 and 0
B. 𝑚𝑛 and 0
C. 𝑚+𝑛 and |𝑚−𝑛|
D. 𝑚𝑛 and m+n
Maximum when no common attribute i.e m*n and minimum when there is a common i.e 0
40. The join operation can be defined as
A. a cartesian product of two relations followed by a selection
B. a cartesian product of two relations
C. a union of two relations followed by cartesian product of the two relations
D. a union of two relations

41. Which operation is used to extract specified columns from a table?


A. Project
B. Join
C. Extract
D. Substitute

42. Suppose the adjacency relation of vertices in a graph is represented in a table Adj (𝑋,𝑌). Which of the
following queries cannot be expressed by a relational algebra expression of constant length?
A. List all vertices adjacent to a given vertex
B. List all vertices which have self loops
C. List all vertices which belong to cycles of less than three vertices
D. List all vertices reachable from a given vertex

43. Consider the following two relations, 𝑅(𝐴,𝐵) and 𝑆(𝐴,𝐶):

𝐴 𝐵
𝑆
10 20
𝐴 𝐶
20 30
10 90
30 40
30 45
30 50
40 80
50 95

The total number of tuples obtained by evaluating the following expression 𝜎𝐵<𝐶(𝑅⋈𝑅.𝐴=𝑆.𝐴 𝑆) is ____2____.

44. Give a relational algebra expression using only the minimum number of operators from (∪,−) which is
equivalent to 𝑅 ∩ S.  R - (R - S)

45. The relational algebra expression equivalent to the following tuple calculus expression:
{𝑡 ∣ 𝑡 ∈ 𝑟 ∧ (𝑡[𝐴] = 10 ∧ 𝑡[𝐵] = 20)} is
A. 𝜎(𝐴=10∨𝐵=20)(𝑟)
B. 𝜎(𝐴=10)(𝑟) ∪ 𝜎(𝐵=20)(𝑟)
C. 𝜎(𝐴=10)(𝑟) ∩ 𝜎(𝐵=20)(𝑟)
D. 𝜎(𝐴=10)(𝑟) − 𝜎(𝐵=20)(𝑟)
Tuple 𝑡 should have two attributes 𝐴 and 𝐵 such that 𝑡.𝐴=10 and 𝑡.𝐵=20.
So, (Tuples having 𝐴=10)∩( Tuples having 𝐵=20)=(Tuples having 𝐴=10 and B=20).

46. A relation 𝑟(𝐴,𝐵) in a relational database has 1200 tuples. The attribute 𝐴 has integer values ranging
from 6 to 20, and the attribute 𝐵 has integer values ranging from 1 to 20. Assume that the
attributes 𝐴 and 𝐵 are independently distributed.
The estimated number of tuples in the output of 𝜎(𝐴>10) ∨ (𝐵=18) (𝑟) is ____________.

𝑃(𝐴>10) = 10/15 = 2/ 3
 𝑃(𝐵=18) = 1/20
 𝑃(𝐴>10∧𝐵=18) = 2/3 × 1/20 = 1/ 30
𝑃(𝐴>10∨𝐵=18) = 𝑃(𝐴>10)+𝑃(𝐵=18) – 𝑃(𝐴>10∧𝐵=18) = 2/3 + 1/20 – 1/30 = (40+3–2) / 60 = 41/60
Estimated number of tuples = 41/60 × 1200 = 820
The above answer is TRUE for SQL SELECT but not for Relational Algebra as by theory relational algebra operates on
a set which means all the elements must be distinct. Since we have 15 distinct possible values for 𝐴 and 20 distinct
possible values for 𝐵, in strict relational algebra we’ll get
Estimated number of tuples= 41/60 × (15×20) = 205.
Official Answer: 205 OR 820
47. Which of the following relational calculus expression is not safe?
A. {𝑡∣∃𝑢∈𝑅1(𝑡[𝐴]=𝑢[𝐴])∧¬∃𝑠∈𝑅2(𝑡[𝐴]=𝑠[𝐴])}
B. {𝑡∣∀𝑢∈𝑅1(𝑢[𝐴]="𝑥"⇒∃𝑠∈𝑅2(𝑡[𝐴]=𝑠[𝐴]∧𝑠[𝐴]=𝑢[𝐴]))}
C. {𝑡∣¬(𝑡∈𝑅1)}
D. {𝑡∣∃𝑢∈𝑅1(𝑡[𝐴]=𝑢[𝐴])∧∃𝑠∈𝑅2(𝑡[𝐴]=𝑠[𝐴])}
It returns tuples not belonging to R1 (which is infinitely many). So, it is not safe.

48. The SQL query


SELECT columns
FROM TableA
RIGHT OUTER JOIN TableB
ON A.columnName = B.columnName
WHERE A.columnName IS NULL
returns the following:
A. All rows in Table B, which meets equality condition above and, none from Table A which
meets the condition.
B. All rows in Table A, which meets equality condition above and none from Table B, which
meets the condition.
C. All rows in Table B, which meets the equality condition
D. All rows in Table A, which meets the equality condition

49. Properties of ‘DELETE’ and ‘TRUNCATE’ commands indicate that


A. After the execution of ‘TRUNCATE’ operation, COMMIT, and ROLLBACK statements
cannot be performed to retrieve the lost data, while ‘DELETE’ allow it
B. After the execution of ‘DELETE’ and ‘TRUNCATE’ operation retrieval is easily possible for
the lost data
C. After the execution of ‘DELETE’ operation, COMMIT and ROLLBACK statements can
be performed to retrieve the lost data, while TRUNCATE do not allow it
D. After the execution of ‘DELETE’ and ‘TRUNCATE’ operation no retrieval is possible for the
lost data

50. Given relations r(w, x) and s(y, z) the result of


select distinct w, x
from r, s
is guaranteed to be same as r, provided.
A. r has no duplicates and s is non-empty
B. r and s have no duplicates
C. s has no duplicates and r is non-empty
D. r and s have the same number of tuples
If 𝑅 has duplicates, in that case, due to distinct keyword those duplicates will be eliminated in final result. So, 𝑅 can not
have duplicates. If 𝑆 is empty 𝑅𝑋𝑆 becomes empty, so 𝑆 must be non empty. This is true.
51. Consider a relational database containing the following schemas.
The primary key of each
table is indicated by sno sname Location
underlining the constituent S1 M/s Royal furniture Delhi
fields. S2 M/s Balaji furniture Bangalore
Catalogue S3 M/s Premium furniture Chennai
Supplies
sno pno Cost
S1 P1 150
S1 P2 50
S1 P3 100
S2 P4 200
S2 P5 250
S3 P1 250
S3 P2 150
S3 P5 300
S3 P4 250
Parts
pno pnmae Part_sec
P1 Table Wood
P2 Chair Wood
P3 Table Steel
P4 Almirah Steel
P5 Almirah Wood

SELECT s.sno, s.sname


FROM Suppliers s, Catalogue c
WHERE s.sno=c.sno AND
cost > (SELECT AVG (cost)
FROM Catalogue
WHERE pno = ‘P4’
GROUP BY pno) ;
The number of rows returned by the above SQL query is
A. 4
B. 5
C. 0
D. 2

52. Consider the following two tables and four queries in SQL.
Book (isbn, bname), Stock(isbn, copies)
Query 1:
SELECT B.isbn, S.copies FROM Book B INNER JOIN Stock S ON B.isbn=S.isbn;
Query 2:
SELECT B.isbn, S.copies FROM Book B LEFT OUTER JOIN Stock S ON B.isbn=S.isbn;
Query 3:
SELECT B.isbn, S,copies FROM Book B RIGHT OUTER JOIN Stock S ON B.isbn=S.isbn
Query 4:
SELECT B.isbn, S.copies FROM Book B FULL OUTER JOIN Stock S ON B.isbn=S.isbn

Which one of the queries above is certain to have an output that is a superset of the outputs of the other
three queries?
A. Query 1
B. Query 2
C. Query 3
D. Query 4
Left Outer Join Only Display in relation Table As Left side Entities
Right Outer Join Display All in Right Side Entities full outer Join showed all Left And Right Along With Null Values

53. What is the output of the following SQL query?


Employee Department OT_allowance
RAMA Mechanical 5000
GOPI Electrical 2000
SINDHU Computer 4000
MAHESH Civil 1500

select count(*) from


((select Employee, Department from Overtime_allowance)
natural join
(select Department, OT_allowance from Overtime_allowance)
as T);
A. 16
B. 4
C. 8
D. None of the above
Same table will be printed after applying natural join  No. of rows by count = 4
54. Consider the following relation
Cinema(theater, address, capacity)
Which of the following options will be needed at the end of the SQL query
SELECT P1.address
FROM Cinema P1
such that it always finds the addresses of theaters with maximum capacity?
A. WHERE P1.capacity >= All (select P2.capacity from Cinema P2)
B. WHERE P1.capacity >= Any (select P2.capacity from Cinema P2)
C. WHERE P1.capacity > All (select max(P2.capacity) from Cinema P2)
D. WHERE P1.capacity > Any (select max(P2.capacity) from Cinema P2

55. SELECT operation in SQL is equivalent to


A. The selection operation in relational algebra
B. The selection operation in relational algebra, except that SELECT in SQL retains duplicates
C. The projection operation in relational algebra
D. The projection operation in relational algebra, except that SELECT in SQL retains
duplicates

56. Consider the following relational schema:


Suppliers (sid:integer, sname:string, saddress:string)
Parts (pid:integer, pname:string, pcolor:string)
Catalog (sid:integer, pid:integer, pcost:real)
What is the result of the following query?
(SELECT Catalog.pid from Suppliers, Catalog
WHERE Suppliers.sid = Catalog.sid)
MINUS
(SELECT Catalog.pid from Suppliers, Catalog
WHERE Suppliers.sname <> 'Sachin' and Suppliers.sid = Catalog.sid)
A. Pid of parts supplied by all except Sachin
B. Pid of parts supplied only by Sachin
C. Pid of parts available in catalog supplied by Sachin
D. Pid of parts available in catalog supplied by all except Sachin
< > means not equal to

57. Consider the following tables 𝑇1 and 𝑇2


T1 T2
P Q R S
2 2 2 2
3 8 8 3
7 3 3 2
5 8 9 7
6 9 5 7
8 5 7 2
9 8
In table 𝑇1 P is the primary key and Q is the foreign key referencing R in table 𝑇2 with on-delete cascade and on-
update cascade. In table 𝑇2, R is the primary key and S is the foreign key referencing P in table 𝑇1 with on-delete set
NULL and on-update cascade. In order to delete record ⟨3,8⟩ from the table 𝑇1, the number of additional records that
need to be deleted from table 𝑇1 is ___0____
58. Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R : All attributes used in the GROUP BY clause must appear in the SELECT clause
S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
A. P and R
B. P and S
C. Q and R
D. Q and S
59. Which of the following is aggregate function in SQL?
A. Avg
B. Select
C. Ordered by
D. Distinct

60. Which commands are used to control access over objects in relational database?
A. CASCADE & MVD
B. GRANT & REVOKE
C. QUE & QUIST
D. None of these

61. Consider the following relation schema pertaining to a students database:


 Students (rollno, name, address)
 Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the student and Enroll tables
are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be present in
(Student * Enroll), where ‘*’ denotes natural join?
A. 8,8
B. 120,8
C. 960,8
D. 960,120

62. In SQL, relations can contain null values, and comparisons with null values are treated as unknown. Suppose
all comparisons with a null value are treated as false. Which of the following pairs is not equivalent?
A. 𝑥=5 𝑛𝑜𝑡(𝑛𝑜𝑡(𝑥=5))
B. 𝑥=5𝑥 > 4 and 𝑥 < 6, where 𝑥 is an integer
C. 𝑥≠5 𝑛𝑜𝑡(𝑥=5)  x= null and any condition with null is false;
D. none of the above

63. Which of the following is/are correct?


A. An SQL query automatically eliminates duplicates
B. An SQL query will not work if there are no indexes on the relations
C. SQL permits attribute names to be repeated in the same relation
D. None of the above

 SQL won’t remove duplicates like relational algebra projection, we have to remove it explicitly by distinct.
 If there are no indexes on the relation SQL will either chose one/more on its own or simply work without any index. No
index would just slow the query but it will surely work.
 SQL does not permit 2 attributes to have same name in a relation.

64. Which of the following statements about a relation 𝑅 in first normal form (1NF) is/are TRUE?
A. 𝑅 can have a multi-attribute key
B. 𝑅 cannot have a foreign key
C. 𝑅 cannot have a composite attribute
D. 𝑅 cannot have more than one candidate key

65. In a relational data model, which one of the following statements is TRUE?
A. A relation with only two attributes is always in BCNF.
B. If all attributes of a relation are prime attributes, then the relation is in BCNF.
C. Every relation has at least one non-prime attribute.
D. BCNF decompositions preserve functional dependencies.

66. The following functional dependencies hold true for the relational schema 𝑅{𝑉,𝑊,𝑋,𝑌,𝑍}:
V→W
VW → X
Y → VX
Y→Z
Which of the following is irreducible equivalent for this set of functional dependencies?
A. V → W
V→X
Y→V
Y→Z
B. V → W
W→X
Y→V
Y→Z
C. V → W
V→X
Y→V
Y→X
Y→Z
D. V → W
W→X
Y→V
Y→X
Y→Z
67. If every non-key attribute functionally dependent on the primary key, then the relation will be in
A. First normal form
B. Second normal form
C. Third normal form
D. Fourth Normal form
1 NF: atomic values 2 NF: Full Functional Dependency. 3 NF: No transitive dependency. BCNF: Super Key

68. For a database relation 𝑅(𝑎,𝑏,𝑐,𝑑) where the domain of 𝑎,𝑏,𝑐 and 𝑑 include only atomic value, only the
following functions dependencies and those that can be inferred from them hold
𝑎→𝑐
𝑏→𝑑
The relation is in:
A. First normal form but not in second normal form
B. Second normal form but not in third normal form
C. Third normal form
D. None of the above

69. A database of research articles in a journal uses the following schema.


(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, YEAR, PRICE)

The primary key is '(VOLUME, NUMBER, STARTPAGE, ENDPAGE)

and the following functional dependencies exist in the schema.


(VOLUME , NUMBER, STARTPAGE, ENDPAGE)→TITLE(VOLUME, NUMBER)→ YEAR(VOLUME,
NUMBER, STARTPAGE, ENDPAGE)→PRICE

The database is redesigned to use the following schemas


(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE) (VOLUME, NUMBER, YEAR)

Which is the weakest normal form that the new database satisfies, but the old one does not?
A. 1NF
B. 2NF
C. 3NF
D. BCNF

70. Consider the relation 𝑋(𝑃,𝑄,𝑅,𝑆,𝑇,𝑈) with the following set of functional dependencies
𝐹={{𝑃,𝑅}→{𝑆,𝑇},{𝑃,𝑆,𝑈}→{𝑄,𝑅}}
Which of the following is the trivial functional dependency in 𝐹+, where 𝐹+ is closure to F?
A. {𝑃,𝑅}→{𝑆,𝑇}  Non Trivial FD
B. {𝑃,𝑅}→{𝑅,𝑇}  Semi Non Trivial FD
C. {𝑃,𝑆}→{𝑆}  Trivial FD
D. {𝑃,𝑆,𝑈}→{𝑄}  Non Trivial FD

71. A prime attribute of a relation scheme 𝑅 is an attribute that appears


A. in all candidate keys of 𝑅
B. in some candidate key of 𝑅  attributes of candidate key is Prime attributes
C. in a foreign key of 𝑅
D. only in the primary key of R

72. Which of the following is TRUE?


A. Every relation in 3NF is also in BCNF
B. A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on
every key of 𝑅
C. Every relation in BCNF is also in 3NF
D. No relation can be in both BCNF and 3NF

73. Which normal form is considered adequate for normal relational database design?
A. 2𝑁𝐹
B. 5𝑁𝐹
C. 4𝑁𝐹
D. 3NF always have decomposition which is dependency preserving and loseless

74. A table has fields 𝐹1,𝐹2,𝐹3,𝐹4,𝐹5 with the following functional dependencies
𝐹1→𝐹3, 𝐹2→𝐹4, (𝐹1.𝐹2)→𝐹5
In terms of Normalization, this table is in
A. 1NF not 2NF as F1  F3 and F2  F4 partial dependency is present
B. 2NF
C. 3NF
D. None of these

75. Relation 𝑅 is decomposed using a set of functional dependencies, 𝐹, and relation 𝑆 is decomposed using
another set of functional dependencies, 𝐺. One decomposition is definitely BCNF, the other is definitely 3𝑁𝐹,
but it is not known which is which. To make a guaranteed identification, which one of the following tests
should be used on the decompositions? (Assume that the closures of 𝐹 and 𝐺 are available).
A. Dependency-preservation
B. Lossless-join
C. BCNF definition
D. 3𝑁𝐹 definition

76. Relation 𝑅 with an associated set of functional dependencies, 𝐹, is decomposed into BCNF. The redundancy
(arising out of functional dependencies) in the resulting set of relations is
A. Zero
B. More than zero but less than that of an equivalent 3𝑁𝐹 decomposition
C. Proportional to the size of F+
D. Indeterminate
If a relation schema is in BCNF then all redundancy based on functional dependency has been removed, although other
types of redundancy may still exist.

77. Given the following relation instance.

X Y Z
1 4 2
1 5 3
1 6 3
3 2 2

Which of the following functional dependencies are satisfied by the instance?


A. 𝑋𝑌→𝑍 and 𝑍→𝑌 2 tends to 2 and 4
B. 𝑌𝑍→𝑋 and 𝑌→𝑍
C. 𝑌𝑍→𝑋 and 𝑋→𝑍 1 tends to 5 and 6
D. 𝑋𝑍→𝑌 and 𝑌→𝑋 (1,3) tends to 5 and 6

78. Consider the schema 𝑅=(𝑆,𝑇,𝑈,𝑉) and the dependencies 𝑆→𝑇,𝑇→𝑈,𝑈→𝑉 and 𝑉→𝑆. Let 𝑅=(𝑅1 and 𝑅2) be a
decomposition such that 𝑅1∩𝑅2≠𝜙. The decomposition is
A. not in 2NF
B. in 2NF but not 3NF
C. in 3NF but not in 2NF
D. in both 2NF and 3NF
Dependencies are S --> T, T --> U, U -->V V --> S
S+ = STUV U+ = UVST
T+ = UVST V+ = VSTU
There is no Partial Dependencies here So it is in 2 NF
RHS of every Dependencies is a Key as well as all are Prime Attributes So it is in 3 NF.

79. R(A, B, C, D) is a relation. Which of the following does not have a lossless join, dependency
preserving 𝐵𝐶𝑁𝐹 decomposition?
A. 𝐴→𝐵,𝐵→𝐶𝐷
B. 𝐴→𝐵,𝐵→𝐶,𝐶→𝐷
C. 𝐴𝐵→𝐶,𝐶→𝐴𝐷
D. 𝐴→𝐵𝐶𝐷
(A) A->B, B->CD

AB and BCD, B is the key of second and hence decomposition is lossless.

(B) A->B, B->C, C->D

AB, BC, CD B is the key of second and C is the key of third, hence lossless.

(C) AB->C, C->AD

ABC, CD. C is key of second, but C->A violates BCNF condition in ABC as C is not a key. We cannot decompose
ABC further as AB->C dependency would be lost. Hence the ANSWER.

(D) A ->BCD  Already in BCNF.

You might also like