Module 3 Study Materials
Module 3 Study Materials
A. A number of tuples.
2.Relational calculus is a:
A. Non-Procedural language.
A.Conceptual view
A.Rename operation.
A.three levels.
A.Tables
A.DDL
A.view level.
A.Tree
A.ellipse
A.not Null
16.The language used in application programs to request data from the DBMS is referred to as the
A.DML
A.data record.
19.The language which has recently become the defacto standard for interfacing application
programs with relational database system
A.SQL
20.The way a particular application views the data from the database that the application uses is a
A.subschema
A.rectangle
A.DML
A.tuple
24.Conceptual design
A.values
A.Hash
A.Alter
A.Network Model
34.Relational Algebra is
A.Foreign Key
A.Cartesian product
A.Attributes
A.Binary
41.Which of the following operation is used if we are interested in only certain columns of a table?
A.projection
Ans:A. CHARACTER
B. NUMERIC
C. FLOAT
A.tuple
B. Derived columns
A.Naïve users.
A.External
A.Domain
50.Which of the operations constitute a basic set of operations for manipulating relational data?
5
A.Relational algebra
A.Child
A.view
GATE DBMS QUESTIONS
Question 1
Consider the following relational schema.
Students(rollno: integer, sname: string)
Courses(courseno: integer, cname: string)
Registration(rollno: integer, courseno: integer, percent: real)
Which of the following queries are equivalent to this query in English?
"Find the distinct names of all students who score
more than 90% in the course numbered 107"
Ans:option A
Question 5
Consider the following relations A, B, C. How many tuples does the result of the following
relational algebra expression contain? Assume that the schema of A U B is the same as that
of A.
Table A
Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11
Table B
Id Name Age
----------------
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11
Table C
Id Phone Area
-----------------
10 2200 02
99 2100 01
A 7
B 4
C 5
D 9
Ans: option A
Question 6
Consider a relational table r with sufficient number of records, having attributes A1, A2,…,
An and let 1 <= p <= n. Two queries Q1 and Q2 are given
below. The database can be configured to do
ordered indexing on Ap or hashing on Ap. Which of the following statements is TRUE?
A Ordered indexing will always outperform hashing for both queries
B Hashing will always outperform ordered indexing for both queries
C Hashing will outperform ordered indexing on Q1, but not on Q2
D Hashing will outperform ordered indexing on Q2, but not on Q1.
Ans: option c
Question 7
1) Let R and S be two relations with the following schema R (P,Q,R1,R2,R3) S (P,Q,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are
equivalent?
A Only I and II
B Only I and III
C Only I, II and III
D Only I, III and IV
Ans: option D
Question 8
Consider the following ER
diagram. The
minimum number of tables needed to represent M, N, P, R1, R2 is
A 2
B 3
C 4
D 5
Ans: option B
Answer is B, i.e, 3 minimum tables. M, P are strong entities hence they must be represented
by separate tables. Many-to-one and one-to-many relationship sets that are total on the many-
side can be represented by adding an extra attribute to the “many” side, containing the
primary key of the “one” side. ( This way no extra table will be needed for Relationship sets )
M table is modified to include primary key of P side(i.e. P1). N is weak entity, and is
modified to include primary key of P (i.e, P1). Therefore there would be minimum of 3 tables
with schema given below :
M ( M1, M2, M3, P1)
P ( P1, P2 )
N ( P1, N1, N2 )
Question 9
Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. F =
{CH -> G, A -> BC, B -> CFH, E -> A, F -> EG} is a set of functional dependencies (FDs)
so that F+ is exactly the set of FDs that hold for R. How many candidate keys does the
relation R have?
A 3
B 4
C 5
D 6
Ans: option B
Explanation: A+ is ABCEFGH which is all attributes except D. B+ is also ABCEFGH which
is all attributes except D. E+ is also ABCEFGH which is all attributes except D. F+ is also
ABCEFGH which is all attributes except D. So there are total 4 candidate keys AD, BD, ED
and FD
Question 10
Consider the FDs given in above question. The relation R is
A in 1NF, but not in 2NF.
B in 2NF, but not in 3NF.
C in 3NF, but not in BCNF.
D in BCNF
Ans: option A
Explanation:
The table is not in 2nd Normal Form as the non-prime attributes are dependent on subsets of
candidate keys. The candidate keys are AD, BD, ED and FD. In all of the following FDs, the
non-prime attributes are dependent on a partial candidate key. A -> BC B -> CFH F -> EG
Question 11
Which of the following is TRUE?
A Every relation in 3NF is also in BCNF
A relation R is in 3NF if every non-prime attribute of R is fully functionally
B
dependent on every key of R
C Every relation in BCNF is also in 3NF
D No relation can be in both BCNF and 3NF
Ans:Option C
Explanation:
BCNF is a stronger version 3NF. So every relation in BCNF will also be in 3NF.
Question 12
Consider a relational table with a single record for each registered student with the following
attributes.
1. Registration_Num: Unique registration number
of each registered student
2. UID: Unique identity number, unique at the
national level for each citizen
3. BankAccount_Num: Unique account number at
the bank. A student can have multiple accounts
or join accounts. This attribute stores the
primary account number.
4. Name: Name of the student
5. Hostel_Room: Room number of the hostel
Which one of the following option is INCORRECT?
A BankAccount_Num is candidate key
B Registration_Num can be a primary key
C UID is candidate key if all students are from the same country
D If S is a superkey such that S∩UID is NULL then S∪UID is also a superkey
Ans:Option A
Explanation:
A Candidate Key value must uniquely identify the corresponding row in table.
BankAccount_Number is not a candidate key. As per the question “A student can have
multiple accounts or joint accounts. This attributes stores the primary account number”. If
two students have a joint account and if the joint account is their primary account, then
BankAccount_Number value cannot uniquely identify a row.
Question 13
Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Assume that, in the suppliers relation above, each supplier and each street within a city has a
unique name, and (sname, city) forms a candidate key. No other functional dependencies are
implied other than those implied by primary and candidate keys. Which one of the following
is TRUE about the above schema?
A The schema is in BCNF
B The schema is in 3NF but not in BCNF
C The schema is in 2NF but not in 3NF
D The schema is not in 2NF
Ans:option A
Explanation:
A relation is in BCNF if for every one of its dependencies X → Y, at least one of the
following conditions hold:
X → Y is a trivial functional dependency (Y ⊆ X)
X is a superkey for schema R
Since (sname, city) forms a candidate key, there is no non-tirvial dependency X → Y where
X is not a superkey
Question 14
Consider the following relational schemes for a library database: Book (Title, Author,
Catalog_no, Publisher, Year, Price) Collection (Title, Author, Catalog_no) with in the
following functional dependencies:
I. Title Author --> Catalog_no
II. Catalog_no --> Title, Author, Publisher, Year
III. Publisher Title Year --> Price
Assume {Author, Title} is the key for both schemes. Which of the following statements is
true?
A Both Book and Collection are in BCNF
B Both Book and Collection are in 3NF only
C Book is in 2NF and Collection is in 3NF
D Both Book and Collection are in 2NF only
Ans:option C
Explanation:
Book (Title, Author, Catalog_no, Publisher, Year, Price)
Collection (Title, Author, Catalog_no)
with in the following functional dependencies:
I. Title, Author --> Catalog_no
II. Catalog_no --> Title, Author, Publisher, Year
III. Publisher, Title, Year --> Price
Question 15
Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, M} and the set of functional
dependencies {{E, F} -> {G}, {F} -> {I, J}, {E, H} -> {K, L}, K -> {M}, L -> {N} on R.
What is the key for R?
A {E, F}
B {E, F, H}
C {E, F, H, K, L}
D {E}
Ans:Option B
Explanation:
All attributes can be derived from {E, F, H} To solve these kind of questions that are
frequently asked in GATE paper, try to solve it by using shortcuts so that enough amount of
time can be saved. Fist Method: Using the given options try to obtain closure of each
options. The solution is the one that contains R and also minimal Super Key, i.e Candidate
Key.
D) {E}+ = {E} ≠ R
Question 16
Given the following two statements:
S1: Every table with two single-valued
attributes is in 1NF, 2NF, 3NF and BCNF.
Question 17
The maximum number of superkeys for the relation schema R(E,F,G,H) with E as the key is
A 5
B 6
C 7
D 8
Ans:Option D
Question 18
Given the STUDENTS relation as shown
below.
For (StudentName, StudentAge) to be the key for this instance, the value X should not be
equal to
A 18
B 19
Ans: option B
Explanation:
There is already an entry with same name and age as 19. So the age of this entry must be
something other than 19.
Question 19
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
Ans: Option B
Explanation:
According to standard SQL answer should be option (C) which is answer key given by
GATE authority. If we talk about different SQL implementations like MySQL, then option
(B) is also right. But in question they seem to be talking about standard SQL not about
implementation. For example below is a P is correct in most of the implementations.
HAVING clause can also be used with aggregate function. If we use a HAVING clause
without a GROUP BY clause, the HAVING condition applies to all rows that satisfy the
search condition. In other words, all rows that satisfy the search condition make up a single
group. See this for more details. S is correct . To verify S, try following queries in SQL.
CREATE TABLE temp
(
id INT,
name VARCHAR(100)
);
SELECT Count(*)
FROM temp
GROUP BY name;
Output:
count(*)
--------
2
1
1
Alternative way - Statement (P) "An SQL query can contain a HAVING clause even if it
does not have a GROUP BY clause" is correct because Having caluse is applied after the
aggregation phase and must be used if you want to filter aggregate results and Having doesn't
require Group By clause. A HAVING clause without a GROUP BY clause is valid and
(arguably) useful syntax in Standard SQL. Consider this example, which is valid Standard
SQL:
SELECT 'T' AS result
FROM Book
HAVING MIN(NumberOfPages) < MAX(NumberOfPages);
Statement (S) "Not all attributes used in the GROUP BY clause need to appear in the
SELECT clause" is correct but if we use Group By clause must, there are limitations on what
we can put into the Select clause.
Question 20
Consider a database table T containing two columns X and Y each of type integer. After the
creation of the table, one record (X=1, Y=1) is inserted in the table. Let MX and My denote
the respective maximum values of X and Y among all records in the table at any point in
time. Using MX and MY, new records are inserted in the table 128 times with X and Y
values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion,
values of MX and MY change. What will be the output of the following SQL query after the
steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;
A 127
B 255
C 129
D 257
Ans:option A
Question 21
Consider the following transactions with data items P and Q initialized to zero:
T1: read (P) ;
read (Q) ;
if P = 0 then Q : = Q + 1 ;
write (Q) ;
T2: read (Q) ;
read (P) ;
if Q = 0 then P : = P + 1 ;
write (P) ;
Any non-serial interleaving of T1 and T2 for concurrent execution leads to
A A serializable schedule
B A schedule that is not conflict serializable
C A conflict serializable schedule
D A schedule for which a precedence graph cannot be drawn
Ans: option B
Question 22
Which of the following concurrency control protocols ensure both conflict serialzability and
freedom from deadlock? I. 2-phase locking II. Time-stamp ordering
A I only
B II only
C Both I and II
D Neither I nor II
Ans:Option B
Explanation:
2 Phase Locking (2PL) is a concurrency control method that guarantees serializability. The
protocol utilizes locks, applied by a transaction to data, which may block (interpreted as
signals to stop) other transactions from accessing the same data during the transaction’s life.
2PL may be lead to deadlocks that result from the mutual blocking of two or more
transactions. See the following situation, neither T3 nor T4 can make progress.
T3:
Which one of the schedules below is the correct serialization of the above?
A T1->>T3->>T2
B T2->>T1->>T3
C T2->>T3->>T1
D T3->>T1->>T2
Ans:option A
Explanation:
T1 can complete before T2 and T3 as there is no conflict between Write(X) of T1 and the
operations in T2 and T3 which occur before Write(X) of T1 in the above diagram.
T3 should can complete before T2 as the Read(Y) of T3 doesn’t conflict with Read(Y) of T2.
Similarly, Write(X) of T3 doesn’t conflict with Read(Y) and Write(Y) operations of T2.
Another way to solve this question is to create a dependency graph and topologically sort the
dependency graph. After topologically sorting, we can see the sequence T1, T3, T2.
Question 24
Consider the following four schedules due to three transactions (indicated by the subscript)
using read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of
them is conflict
serializable.
A A
B B
C C
D D
Ans:option D
Explanation:
In option D, there is no interleaving of operations. The option D has first all operations of
transaction 2, then 3 and finally 1 There can not be any conflict as it is a serial schedule with
sequence 2 --> 3 -- > 1
Question 5
Consider the following schedule S of transactions T1, T2, T3,
T4:
Explanation:
To check for conflict-serializable, we need to make a precedence graph, if the graph contains
a cycle, then it's not conflict serializable, else it is. Here, for the precedence graph there will
be only two directed edges, one from T2 -> T3 ( Read- Write Conflict), and another from T2
-> T1( Read- Write Conflict), hence no cycle, so the schedule is conflict serializable. Now to
check for Recoverable, we need to check for a dirty-read operation( Write by Transaction Ti,
followed by Read by Transaction Tj but before Ti commits) between any pair of operations.
If no dirty-read then recoverable schedule, if a dirty read is there then we need to check for
commit operations. Here no dirty read operation ( as T3 and T1 commits before T4 reads the
Write(X) of T3 and T1 , and T2 commits before T4 reads the Write(Y) of T2 ). Therefore the
schedule is recoverable. Hence, Option C.