Gate Questions: Database Management Systems
Gate Questions: Database Management Systems
GATE QUESTIONS
DATABASE MANAGEMENT
SYSTEMS
2019 – 2020 EVEN
Prepared by
R. Arthy, AP/IT
Section 5: Algorithms
Searching, sorting, hashing. Asymptotic worst case time and space complexity. Algorithm design
techniques: greedy, dynamic programming and divide‐and‐conquer. Graph search, minimum spanning
trees, shortest paths.
Section 9: Databases
ER‐model. Relational model: relational algebra, tuple calculus, SQL. Integrity constraints, normal
forms. File organization, indexing (e.g., B and B+ trees). Transactions and concurrency control.
ii
CS8492 DATABASE MANAGEMENT SYSTEMS L T P C 3 0 03
OBJECTIVES
Classify the modern and futuristic database applications based on size and complexity
Map ER model to Relational model to perform database design effectively
Write queries using normalization criteria and optimize queries
Compare and contrast various indexing strategies in different database systems
Appraise how advanced databases differ from traditional databases.
iii
DEPARTMENT OF INFORMATION TECHNOLOGY
GATE QUESTIONS
CS6660 – COMPILER DESIGN
INDEX
-
Academic Year : 2019 – 2020 EVEN
Question Paper Year : 2000 to 2019
Name of the Subject In – Charge : Mrs. R. Arthy, AP/IT
Name(s) of the Student Mentor :
-
Number of
S. No. Name of the Topic Page Number
Questions
1 Relational Algebra 15 1 - 15
2 SQL 20 16 - 33
3 ER Diagram 7 34 - 38
4 Normalization 34 39 - 54
5 Transactions 18 55 - 64
6 File Structure 8 65 - 69
iv
DEPARTMENT OF INFORMATION TECHNOLOGY
GATE QUESTIONS
CS8492 – DATABASE MANAGEMENT SYSTEMS
ASSESSMENT REPORT
Signature Signature
Question
Mark of the of the
S. No. Date Hour Name of the Topic Numbers
(10) Student Subject In
Solved
Mentor – Charge
v
Signature Signature
Question
Mark of the of the
S. No. Date Hour Name of the Topic Numbers
(10) Student Subject In
Solved
Mentor – Charge
vi
CERTIFICATE OF COMPLETION
vii
CS8492 – Database Management Systems
1.1 Consider the following relation P(X, Y, Z), Q(X, Y, T) and R(Y, V):
How many tuples will be returned by the following relational algebra query?
πx(σ(P.Y = R.Y ∧ R.V = V(P X R))) - πx(σ(Q.Y = R.Y ∧ Q.T > 2(Q X R)))
Note: This was Numerical Type question.
GATE | GATE CS 2019 | Question 63
(A) 3
(B) 1
(C) 2
(D) 4
1.2 Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key
referencing s.B. Consider the query
Q: r⋈(σB<5(s))
Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which one of the following is NOT equivalent to Q?
GATE | GATE CS 2018 | Question 59
(A) σB<5(r ⋈ s)
(B) σB<5(r LOJ s)
(C) r LOJ (σB<5(s))
(D) σB<5(r)LOJ s
1.3 The following functional dependencies hold true for the relational schema R{V, W, X, Y, Z}:
V -> W
VW -> X
Y -> VX
Y -> Z
Which of the following is irreducible equivalent for this set of functional dependencies?
(A) A
(B) B
(C) C
(D) D
1.4 Consider a database that has the relation schemas EMP (EmpId, EmpName, DepId), and
DEPT(DeptName, DeptId). Note that the DepId can be permitted to be NULL in the relation EMP.
Consider the following queries on the database expressed in tuple relational calculus.
I. {t | ∃ u ∈ EMP (t[EMPName] = u[EmpName] ∧ ∀ v ∈ DEPT (t[DeptId] ≠ DeptId]))}
II. {t | ∃ u ∈ EMP (t[EMPName] = u[EmpName] ∧ ∃ v ∈ DEPT (t[DeptId] ≠ DeptId]))}
1.5 Consider a database that has the relation schema CR(StudentName, CourseName). An instance
of the schema CR is as given below.
T1 ← πCourseName(σStudentName=’SA’(CR))
T2 ← CR ÷ T1
The number of rows in T2 is ________.
Note: This questions appeared as Numerical Answer Type.
GATE | GATE-CS-2017 (Set 1) | Question 59
(A) 2
(B) 3
(C) 4
(D) 5
1.6 Suppose (A, B) and (C,D) are two relation schemas. Let r1 and r2 be the corresponding relation
instances. B is a foreign key that refers to C in r2. If data in r1 and r2 satisfy referential integrity
constraints, which of the following is ALWAYS TRUE?
(A) A
(B) B
(C) C
(D) D
1.7 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
GATE | GATE CS 2012 | Question 50
(A) 7
(B) 4
(C) 5
(D) 9
1.8 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?
GATE | GATE CS 2011 | Question 39
(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.
1.9 Which of the following tuple relational calculus expression(s) is/are equivalent to
(A) I only
(B) II only
(C) III only
(D) III and IV only
1.12 Consider the relation employee(name, sex, supervisorName) with name as the key.
supervisorName gives the name of the supervisor of the employee under consideration.
What does the following Tuple Relational Calculus query produce?
1.13 Consider a join (relation algebra) between relations r(R)and s(S) using the nested loop method.
There are 3 buffers each of size equal to disk block size, out of which one buffer is reserved for
intermediate results. Assuming size(r(R)) < size(s(S)), the join will have fewer number of disk block
accesses if
GATE | GATE-CS-2014-(Set-2) | Question 65
1.14
GATE | GATE-CS-2014-(Set-3) | Question 65
(A) A
(B) B
(C) C
(D) D
1.15 Consider the relational schema given below, where eId of the relation dependent is a foreign key
referring to empId of the relation employee. Assume that every employee has at least one associated
dependent in the dependent relation.
employee (empId, empName, empAge)
dependent(depId, eId, depName, depAge)
Consider the following relational algebra query:
The above query evaluates to the set of empIds of employees whose age is greater than that of
GATE | GATE-CS-2014-(Set-3) | Question 65
TOPIC: SQL
2.1 A relational database contains two tables Student and Performance as shown below:
The primary key of the Student table is Roll_no. For the Performance table, the columns Roll_no. and
Subject_code together from the primary key. Consider the SQL query given below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;
The number of rows returned by the above SQL query is _________ .
Note: This was Numerical Type question.
GATE | GATE CS 2019 | Question 61
(A) 5
(B) 4
(C) 3
(D) None of these.
2.2 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 B 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 B 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?
GATE | GATE CS 2018 | Question 29
(A) Query 1
(B) Query 2
(C) Query 3
(D) Query 4
2.3 Consider a database that has the relation schema EMP (EmpId, EmpName, and DeptName). An
instance of the schema EMP and a SQL query on it are given below.
(A) 1.2
(B) 2.3
(C) 2.6
(D) 3.1
(A) 6
(B) 7
(C) 8
(D) 9
TOPIC: SQL
2.5 Which of the following is NOT a superkey in a relational schema with attributes V, W, X, Y, Z
and primary key V Y ?
GATE | GATE-CS-2016 (Set 1) | Question 31
(A) V X Y Z
(B) V W X Z
(C) V W X Y
(D) V W X Y Z
(A) 1
(B) 2
(C) 3
(D) 4
TOPIC: SQL
(A) 0
(B) 1
(C) 2
(D) 3
(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)
TOPIC: SQL
2.10 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
GATE | GATE CS 2012 | Question 15
(A) P and R
(B) P and S
(C) Q and R
(D) Q and S
4.11 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
Consider the above tables A, B and C. How many tuples does the result of the following SQL query
contains?
SELECT A.id FROM A WHERE A.age > ALL (SELECT B.age FROM B WHERE B. name =
"arun")
GATE | GATE CS 2012 | Question 51
(A) 4
(B) 3
(C) 0
(D) 1
2.12 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;
GATE | GATE CS 2011 | Question 32
(A) 127
(B) 255
(C) 129
(D) 257
TOPIC: SQL
(A) 3
(B) 9
(C) 5
(D) 6
Table : Reservation
pid class tid
---------------
0 AC 8200
1 AC 8201
2 SC 8201
5 AC 8203
1 SC 8204
3 AC 8202
What pids are returned by the following SQL query for the above instance of the tables?
SLECT pid FROM Reservation WHERE class ‘AC’ AND EXISTS (SELECT * FROM Passenger
WHERE age > 65 AND Passenger. pid = Reservation.pid)
GATE | GATE CS 2010 | Question 19
(A) 1, 0
(B) 1, 2
(C) 1, 3
(D) 1, 5
(A) Find the names of all suppliers who have supplied a non-blue part.
(B) Find the names of all suppliers who have not supplied a non-blue part.
(C) Find the names of all suppliers who have supplied only blue parts.
(D) Find the names of all suppliers who have not supplied only blue parts.
(E) None
2.16 Consider the table employee(empId, name, department, salary) and the two queries Q1 ,Q2
below. Assuming that department 5 has more than one employee, and we want to find the employees
who get higher salary than anyone in the department 5, which one of the statements is TRUE for any
arbitrary employee table?
Q1 : Select e.empId From employee e Where not exists (Select * From employee s where
s.department = “5” and s.salary >=e.salary)
Q2 : Select e.empId From employee e Where e.salary > Any (Select distinct salary From employee s
Where s.department = “5”)
GATE | GATE-CS-2007 | Question 61
TOPIC: SQL
2.18 SQL allows tuples in relations, and correspondingly defines the multiplicity of tuples in the result
of joins. Which one of the following queries always gives the same answer as the nested query shown
below:
select * from R where a in (select S.a from S)
GATE | GATE-CS-2014-(Set-2) | Question 65
TOPIC: SQL
(A) Names of all the employees with at least one of their customers having a ‘GOOD’ rating.
(B) Names of all the employees with at most one of their customers having a ‘GOOD’ rating.
(C) Names of all the employees with none of their customers having a ‘GOOD’ rating.
(D) Names of all the employees with all their customers having a ‘GOOD’ rating.
2.20 Consider the relation account (customer, balance) where customer is a primary key and there are
no null values. We would like to rank customers according to decreasing balance. The customer with
the largest balance gets rank 1. ties are not broke but ranks are skipped: if exactly two customers have
the largest balance they each get rank 1 and rank 2 is not assigned
Query1:
select A.customer, count(B.customer) from account A, account B where A.balance <=B.balance
group by A.customer
Query2:
select A.customer, 1+count(B.customer) from account A, account B where A.balance < B.balance
group by A.customer
Consider these statements about Query1 and Query2.
1. Query1 will produce the same row set as Query2 for some but not all databases.
2. Both Query1 and Query2 are correct implementation of the specification
3. Query1 is a correct implementation of the specification but Query2 is not
4. Neither Query1 nor Query2 is a correct implementation of the specification
5. Assigning rank with a pure relational query takes less time than scanning in decreasing balance
order assigning ranks using ODBC.
Which two of the above statements are correct?
GATE | GATE-CS-2006 | Question 67
(A) 2 and 5
(B) 1 and 3
(C) 1 and 4
(D) 3 and 5
2.21 Consider the relation “enrolled(student, course)” in which (student, course) is the primary key,
and the relation “paid(student, amount)” where student is the primary key. Assume no null values and
no foreign keys or integrity constraints. Given the following four queries:
Query1: select student from enrolled where student in (select student from paid)
Query2: select student from paid where student in (select student from enrolled)
Query3: select E.student from enrolled E, paid P where E.student = P.student
Query4: select student from paid where exists (select * from enrolled where enrolled.student
= paid.student)
Which one of the following statements is correct?
GATE | GATE-CS-2006 | Question 68
(A) All queries return identical row sets for any database
(B) Query2 and Query4 return identical row sets for all databases but there exist databases for which
Query1 and Query2 return different row sets.
(C) There exist databases for which Query3 returns strictly fewer rows than Query2
(D) There exist databases for which Query4 will encounter an integrity violation at runtime.
2.22 The following table has two attributes A and C where A is the primary key and C is the foreign
key referencing A with on-delete cascade.
A C
-----
2 4
3 4
4 3
5 2
7 2
9 5
6 4
The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple
(2,4) is deleted is:
GATE | GATE-CS-2005 | Question 76
TOPIC: SQL
2.23 The relation book (title, price) contains the titles and prices of different books. Assuming that no
two books have the same price, what does the following SQL query list?
select title from book as B where (select count(*) from book as T where T.price > B.price) < 5
GATE | GATE-CS-2005 | Question 77
(A) 8, 8
(B) 120, 8
(C) 960, 8
(D) 960, 120
(A) the average salary is more than the average salary in the company
(B) the average salary of male employees is more than the average salary of all male employees in the
company
(C) the average salary of male employees is more than the average salary of employees in the same
department
(D) the average salary of male employees is more than the average salary in the company
2.26 Consider the set of relations shown below and the SQL query that follows.
Students: (Roll_number, Name, Date_of_birth)
Courses: (Course number, Course_name, Instructor)
Grades: (Roll_number, Course_number, Grade)
select distinct Name from Students, Courses, Grades where Students. Roll_number =
Grades.Roll_number and Courses.Instructor = Korth and Courses.Course_number =
Grades.Course_number and Grades.grade = A
GATE | GATE-CS-2003 | Question 86
TOPIC: SQL
2.28 A company maintains records of sales made by its salespersons and pays them commission based
on each individual’s total sales made in a year. This data is maintained in a table with following
schema:
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons
by enhancing the commission paid to them as per the following formula:
If commission < = 50000, enhance it by 2%
If 50000 < commission < = 100000, enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of
these scripts is to run as a separate transaction as follows:
Update salesinfo Set commission = commission * 1.02 Where commission < =
T1 50000;
2.29 A table ‘student’ with schema (roll, name, hostel, marks), and another table ‘hobby’ with schema
(roll, hobbyname) contains records as shown below:
ROLL NAME HOSTEL MARKS
Table: Student
ROLL HOBBYNAME
1798 chess
1798 music
2154 music
2369 swimming
2581 cricket
2643 chess
2643 hockey
2711 volleyball
2872 football
2926 cricket
2959 photography
3125 music
3125 chess
Table: hobby
The following SQL query is executed on the above tables:
select hostel from student natural join hobby where marks > = 75 and roll between 2000 and 3000;
Relations S and H with the same schema as those of these two tables respectively contain the same
information as tuples. A new relation S’ is obtained by the following relational algebra operation:
S’ = ∏hostel ((σs.roll = H.roll (σmarks > 75 and roll > 2000 and roll < 3000 (S)) X (H))
The difference between the number of rows output by the SQL statement and the number of tuples in
S’ is
GATE | Gate IT 2005 | Question 68
(A) 6
(B) 4
(C) 2
(D) 0
TOPIC: SQL
2.30 In an inventory management system implemented at a trading corporation, there are several
tables designed to hold all the information. Amongst these, the following two tables hold information
on which items are supplied by which suppliers, and which warehouse keeps which items along with
the stock-level of these items.
Supply = (supplierid, itemcode)
Inventory = (itemcode, warehouse, stocklevel)
For a specific information required by the management, following SQL query has been written
Select distinct STMP.supplierid From Supply as STMP Where not unique (Select ITMP.supplierid
From Inventory, Supply as ITMP Where STMP.supplierid = ITMP.supplierid
And ITMP.itemcode = Inventory.itemcode And Inventory.warehouse = 'Nagpur');
For the warehouse at Nagpur, this query will find all suppliers who
GATE | Gate IT 2005 | Question 69
TOPIC: ER Diagram
3.1. In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity set E1
to entity set E2. Assume that E1 and E2 participate totally in R and that the cardinality of E1 is greater
that the cardinality of E2.
Which one of the following is true about R?
GATE | GATE CS 2018 | Question 24
3.2. An ER model of a database consists of entity types A and B. These are connected by a
relationship R which does not have its own attribute. Under which of the following conditions, can the
relational table for R be merged with that of A?
GATE | GATE-CS-2017 (Set 2) | Question 16
(A) A
(B) B
(C) C
(D) D
3.3. Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an
m : n relationship R12, E1 and E3 are connected by a 1 : n (1 on the side of E1 and n on the side of E3)
relationship R13.
E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-
valued attributes a21 and a22 is the key attribute. E3 has two single-valued attributes a31 and a32 of
which a31 is the key attribute. The relationships do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that
would be generated if all the relations are in 3NF is ___________.
GATE | GATE-CS-2015 (Set 1) | Question 65
(A) 2
(B) 3
(C) 4
(D) 5
TOPIC: ER Diagram
(A) 2
(B) 3
(C) 4
(D) 5
3.5. Consider the data given in above question. Which of the following is a correct attribute set for
one of the tables for the correct answer to the above question?
3.6. Given the basic ER and relational models, which of the following is INCORRECT?
GATE | GATE CS 2012 | Question 14
3.7. Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1 and R2
are two relationships between E1 and E2, where R1 is one-to-many and R2 is many-to-many. R1 and
R2 do not have any attributes of their own. What is the minimum number of tables required to
represent this situation in the relational model?
GATE | GATE-CS-2005 | Question 90
(A) 2
(B) 3
(C) 4
(D) 5
TOPIC: Normalization
4.1. Let the set of functional dependencies F = {QR → S, R → P, S → Q} hold on a relation schema
X = (PQRS). X is not in BCNF. Suppose X is decomposed into two schemas and Z where Y = (PR)
and Z = (QRS). Consider the two statements given below:
I. Both Y and Z are in BCNF
II. Decomposition of X into Y and Z is dependency preserving and a lossless.
Which of the above statements is/are correct?
GATE | GATE CS 2019 | Question 41
(A) I only
(B) Neither I nor II
(C) Both I and II
(D) II only
4.2 Consider the following four relational schemas. For each schema, all non-trivial functional
dependencies are listed, The underlined attributes are the respective primary keys.
Schema I: Registration(rollno, courses)
Field ‘courses’ is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency
rollno → courses
Schema II: Registration (rollno, coursid, email)
Non-trivial functional dependencies:
rollno, courseid → email
email → rollno
Schema III: Registration (rollno, courseid, marks, grade)
Non-trivial functional dependencies:
rollno, courseid, → marks, grade
marks → grade
Schema IV: Registration (rollno, courseid, credit)
Non-trivial functional dependencies:
rollno, courseid → credit
courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
GATE | GATE CS 2018 | Question 64
(A) Schema I
(B) Schema II
(C) Schema III
(D) Schema IV
(A) 1NF
(B) 2NF
(C) 3NF
(D) BCNF
4.4 Consider the relation X(P, Q, R, S, T, U) with the following set of functional dependencies
F={
{P, R} → {S,T},
{P, S, U} → {Q, R}
}
Which of the following is the trivial functional dependency in F+ is closure of F?
GATE | GATE-CS-2015 (Set 3) | Question 65
(A) {P,R}→{S,T}
(B) {P,R}→{R,T}
(C) {P,S}→{S}
(D) {P,S,U}→{Q}
TOPIC: Normalization
4.5. 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?
GATE | GATE CS 2013 | Question 54
(A) 3
(B) 4
(C) 5
(D) 6
4.8 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?
GATE | GATE CS 2011 | Question 65
TOPIC: Normalization
4.11 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?
GATE | GATE-CS-2014-(Set-1) | Question 31
(A) {E, F}
(B) {E, F, H}
(C) {E, F, H, K, L}
(D) {E}
S2: AB->C, D->E, E->C is a minimal cover for the set of functional dependencies
AB->C, D->E, AB->E, E->C.
Which one of the following is CORRECT?
GATE | GATE-CS-2014-(Set-1) | Question 40
TOPIC: Normalization
4.13 The maximum number of superkeys for the relation schema R(E,F,G,H) with E as the key is
GATE | GATE-CS-2014-(Set-2) | Question 31
(A) 5
(B) 6
(C) 7
(D) 8
4.14 Let R1 (A, B, C) and R2 (D, E) be two relation schema, where the primary keys are shown
underlined, and let C be a foreign key in R1 referring to R2. Suppose there is no violation of the
above referential integrity constraint in the corresponding relation instances r1 and r2. Which one of
the following relational algebra expressions would necessarily produce an empty relation ?
(A) 1
(B) 2
(C) 3
(D) 4
4.15 The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following
functional dependencies:
name, courseNo → grade
rollNo, courseNo → grade
name → rollNo
rollNo → name
The highest normal form of this relation scheme is
GATE | GATE-CS-2004 | Question 90
(A) 2 NF
(B) 3 NF
(C) BCNF
(D) 4NF
4.17 Relation R with an associated set of functional dependencies, F is decomposed into BCNF. The
redundancy (arising out of functional dependencies) in the resulting set relations is.
GATE | GATE-CS-2002 | Question 23
(A) Zero
(B) More than zero but less than that of an equivalent 3NF decomposition
(C) Proportional to the size of F+
(D) Indeterminate
4.18 With regard to the expressive power of the formal relational query languages, which of the
following statements is true?
GATE | GATE-CS-2002 | Question 20
4.19 Relation R is decomposed using a set of functional dependencies, F and relation S is decomposed
using another set of functional dependencies G. One decomposition is definitely BCNF, the other is
definitely 3NF, 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 F and G are
available).
GATE | GATE-CS-2002 | Question 50
(A) Dependency-preservation
(B) Lossless-join
(C) BCNF definition
(D) 3NF definition
TOPIC: Normalization
4.20 From the following instance of a relation scheme R (A, B, C), we can conclude that :
A B C
1 1 1
1 1 0
2 3 2
2 3 2
GATE | GATE-CS-2002 | Question 50
4.21 Consider a schema R(A,B,C,D) and functional dependencies A->B and C->D.
Then the decomposition of R into R1(AB) and R2(CD) is
GATE | GATE-CS-2001 | Question 23
TOPIC: Normalization
4.22 Suppose the adjacency relation of vertices in a graph is represented in a table Adj(X,Y). Which
of the following queries cannot be expressed by a relational algebra expression of constant length?
GATE | GATE-CS-2001 | Question 24
4.23 Let r and s be two relations over the relation schemes R and S respectively, and let A be an
attribute in R. then the relational algebra expression is always equal to
(A) A
(B) B
(C) C
(D) D
TOPIC: Normalization
4.24 R(A,B,C,D) is a relation. Which of the following does not have a lossless join, dependency
preserving BCNF decomposition?
GATE | GATE-CS-2001 | Question 48
(A) A
(B) B
(C) C
(D) D
4.26 Consider a relation geq which represents “greater than or equal to”, that is, (x,y) ∈ geq only if
y >= x.
create table geq
(
ib integer not null
ub integer not null
primary key 1b
foreign key (ub) references geq on delete cascade
)
Which of the following is possible if a tuple (x,y) is deleted?
GATE | GATE-CS-2001 | Question 50
TOPIC: Normalization
4.29 Consider the following entity relationship diagram (ERD), where two entities E1 and E2 have a
relation R of cardinality 1 : m.
The attributes of E1 are A11, A12 and A13 where A11 is the key attribute. The attributes of E2 are
A21, A22 and A23 where A21 is the key attribute and A23 is a multi-valued attribute. Relation R
does not have any attribute. A relational database containing minimum number of tables with each
table satisfying the requirements of the third normal form (3NF) is designed from the above ERD. The
number of tables in the database is
GATE | GATE-IT-2004 | Question 73
(A) 2
(B) 3
(C) 5
(D) 4
4.30 A relational database contains two tables student and department in which student table has
columns roll_no, name and dept_id and department table has columns dept_id and dept_name. The
following insert statements were executed successfully to populate the empty tables:
Insert into department values (1, 'Mathematics')
Insert into department values (2, 'Physics')
Insert into student values (l, 'Navin', 1)
Insert into student values (2, 'Mukesh', 2)
Insert into student values (3, 'Gita', 1)
How many rows and columns will be retrieved by the following SQL statement?
Select * from student, department
GATE | GATE-IT-2004 | Question 74
4.31 Consider the entities ‘hotel room’, and ‘person’ with a many to many relationship ‘lodging’ as
shown below:
(A) Person
(B) Hotel Room
(C) Lodging
(D) None of these
4.32 A table has fields Fl, F2, F3, F4, F5 with the following functional dependencies
F1 → F3 F2→ F4 (F1 . F2) → F5
In terms of Normalization, this table is in
GATE | Gate IT 2005 | Question 22
(A) 1 NF
(B) 2 NF
(C) 3 NF
(D) none
TOPIC: Normalization
4.33 Let R (A, B, C, D, E, P, G) be a relational schema in which the following functional depen-
dencies are known to hold: AB → CD, DE → P, C → E, P → C and B → G. The relational schema R
is
GATE | Gate IT 2008 | Question 60
(A) in BCNF
(B) in 3NF, but not in BCNF
(C) in 2NF, but not in 3NF
(D) not in 2NF
(A) CD
(B) EC
(C) AE
(D) AC
TOPIC: TRANSACTIOM
5.1 In a database system, unique time stamps are assigned to each transaction using Lamport’s logical
clock. Let TS(T1) and TS(T2) be the time stamps of transactions T1 and T2 respectively. Besides, T1
holds a lock on the resource R, and T2 has requested a conflicting lock on the same resource R. The
following algorithm is used to prevent deadlocks in the database assuming that a killed transaction is
restarted with the same timestamp.
if TS(T2) <TS(T1) then
T1 is killed
else T2 waits.
Assume any transactions that is not killed terminates eventually. Which of the following is TRUE
about the database system that uses the above algorithm to prevent deadlocks?
GATE | GATE-CS-2017 (Set 1) | Question 46
5.2 Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or
write operations), a certain set of objects {O1,…,Ok}. This is done in the following manner:
Step 1. T acquires exclusive locks to O1, . . . , Ok in increasing order of their addresses.
Step 2. The required operations are performed.
Step 3. All locks are released.
This protocol will
GATE | GATE-CS-2016 (Set 1) | Question 61
5.3 Which one of the following is NOT a part of the ACID properties of database transactions?
GATE | GATE-CS-2016 (Set 1) | Question 32
(A) Atomicity
(B) Consistency
(C) Isolation
(D) Deadlock-freedom
5.4 Consider the following database schedule with two transactions, T1 and T2.
S = r2(X); r1(X); r2(Y); w1(X); r1(Y); w2(X); a1; a2;
where ri(Z) denotes a read operation by transaction Ti on a variable Z, wi(Z) denotes a write operation
by Ti on a variable Z and ai denotes an abort by transaction Ti .
Which one of the following statements about the above schedule is TRUE?
GATE | GATE-CS-2016 (Set 2) | Question 61
(A) S is non-recoverable
(B) S is recoverable, but has a cascading abort
(C) S does not have a cascading abort
(D) S is strict
TOPIC: TRANSACTIOM
5.5 A file is organized so that the ordering of data records is the same as or close to the ordering of
data entries in some index. Then that index is called
GATE | GATE-CS-2015 (Set 1) | Question 65
(A) Dense
(B) Sparse
(C) Clustered
(D) Unclustered
5.6 Consider the following transaction involving two bank accounts x and y.
read(x); x := x – 50; write(x); read(y); y := y + 50; write(y)
The constraint that the sum of the accounts x and y should remain constant is that of
GATE | GATE-CS-2015 (Set 2) | Question 11
(A) Atomicity
(B) Consistency
(C) Isolation
(D) Durability
5.7 Consider a simple checkpointing protocol and the following set of operations in the log.
(start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7);
(checkpoint);
(start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3); (write, T3, z, 7, 2);
If a crash happens now and the system tries to recover using both undo and redo operations, what are
the contents of the undo list and the redo list
GATE | GATE-CS-2015 (Set 2) | Question 56
5.8 Consider the following partial Schedule S involving two transactions T1 and T2. Only the read
and the write operations have been shown. The read operation on data item P is denoted by read(P)
and the write operation on data item P is denoted by write(P).
Suppose that the transaction T1 fails immediately after time instance 9. Which one of the following
statements is correct?
GATE | GATE-CS-2015 (Set 3) | Question 40
(A) T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction
atomicity
(B) Schedule S is non-recoverable and cannot ensure transaction atomicity
(C) Only T2 must be aborted and then re-started to ensure transaction atomicity
(D) Schedule S is recoverable and can ensure atomicity and nothing else needs to be done
TOPIC: TRANSACTIOM
5.9 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
GATE | GATE CS 2012 | Question 25
5.10 Which of the following concurrency control protocols ensure both conflict serialzability and
freedom from deadlock?
I. 2-phase locking
II. Time-stamp ordering
GATE | GATE CS 2010 | Question 20
(A) I only
(B) II only
(C) Both I and II
(D) Neither I nor II
5.11 Consider the following schedule for transactions T1, T2 and T3:
Which one of the schedules below is the correct serialization of the above?
GATE | GATE CS 2010 | Question 42
(A) T1->>T3->>T2
(B) T2->>T1->>T3
(C) T2->>T3->>T1
(D) T3->>T1->>T2
5.12 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
TOPIC: TRANSACTIOM
5.13 Consider the following schedule S of transactions T1, T2, T3, T4:
5.14 Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below.
T1: r1(X); r1(Z); w1(X); w1(Z)
T2: r2(Y); r2(Z); w2(Z)
T3: r3(Y); r3(X); w3(Y)
S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z);
w3(Y); w2(Z); r1(Z); w1(X); w1(Z)
S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z);
r2(Z); w3(Y); w1(X); w2(Z); w1(Z)
Which one of the following statements about the schedules is TRUE?
GATE | GATE-CS-2014-(Set-3) | Question 65
5.15 Consider the following log sequence of two transactions on a bank account, with initial balance
12000, that transfer 2000 to a mortgage payment and then apply a 5% interest.
1. T1 start
2. T1 B old=12000 new=10000
3. T1 M old=0 new=2000
4. T1 commit
5. T2 start
6. T2 B old=10000 new=10500
7. T2 commit
Suppose the database system crashes just before log record 7 is written. When the system is restarted,
which one statement is true of the recovery procedure?
GATE | GATE-CS-2006 | Question 85
5.16 Which of the following scenarios may lead to an irrecoverable error in a database system ?
GATE | GATE-CS-2003 | Question 29
TOPIC: TRANSACTIOM
5.17 Consider three data items D1, D2 and D3 and the following execution schedule of transactions
T1, T2 and T3. In the diagram, R(D) and W(D) denote the actions reading and writing the data item D
respectively.
Read(A)A = A – 10 Read(B)
Write(A)Read(B)
B = B + 10
Write(B) B = B + TempWrite(B)
GATE | GATE-IT-2004 | Question 77
5.20 Consider the following three schedules of transactions T1, T2 and T3. [Notation: In the
following NYO represents the action Y (R for read, W for write) performed by transaction N on
object O.]
(S1) 2RA 2WA 3RC 2WB 3WA 3WC 1RA 1RB 1WA 1WB
(S2) 3RC 2RA 2WA 2WB 3WA 1RA 1RB 1WA 1WB 3WC
(S3) 2RA 3RC 3WA 2WA 2WB 3WC 1RA 1RB 1WA 1WB
Which of the following statements is TRUE?
GATE | Gate IT 2008 | Question 61
5.18 Which level of locking provides the highest degree of concurrency in a relational data base?
GATE | GATE-IT-2004 | Question 21
(A) Page
(B) Table
(C) Row
(D) Page, table and row level locking allow the same degree of concurrency
6.1 With reference to the B+ tree index of order 1 shown below, the minimum number of nodes
(including the root node) that must be fetched in order to satisfy the following query: “Get all records
with a search key greater than or equal to 7 and less than 15” is ________
(A) 4
(B) 5
(C) 6
(D) 7
6.2 Consider B+ tree in which the search key is 12 bytes long, block size is 1024 bytes, record pointer
is 10 bytes long and block pointer is 8 bytes long. The maximum number of keys that can be
accommodated in each non-leaf node of the tree is
GATE | GATE-CS-2015 (Set 3) | Question 56
(A) 49
(B) 50
(C) 51
(D) 52
6.4 Consider a B+-tree in which the maximum number of keys in a node is 5. What is the minimum
number of keys in any non-root node?
GATE | GATE CS 2010 | Question 18
(A) 1
(B) 2
(C) 3
(D) 4
6.5 A FAT (file allocation table) based file system is being used and the total overhead of each entry
in the FAT is 4 bytes in size. Given a 100 x 106 bytes disk on which the file system is stored and data
block size is 103 bytes, the maximum size of a file that can be stored on this disk in units of 10 6 bytes
is ____________.
GATE | GATE-CS-2014-(Set-2) | Question 65
6.6 In the index allocation scheme of blocks to a file, the maximum possible size of the file depends
on :
GATE | GATE-CS-2002 | Question 47
(A) the size of the blocks, and the size of the address of the blocks.
(B) the number of blocks used for the index, and the size of the blocks.
(C) the size of the blocks, the number of blocks used for the index, and the size of the address of the
blocks.
(D) None of these
6.7 A database table T1 has 2000 records and occupies 80 disk blocks. Another table T2 has 400
records and occupies 20 disk blocks. These two tables have to be joined as per a specified join
condition that needs to be evaluated for every pair of records from these two tables. The memory
buffer space available can hold exactly one block of records for T1 and one block of records for T2
simultaneously at any point in time. No index is available on either table.
If Nested-loop join algorithm is employed to perform the join, with the most appropriate choice of
table to be used in outer loop, the number of block accesses required for reading the data are
GATE | Gate IT 2005 | Question 84
Q 82_Part A
(A) 800000
(B) 40080
(C) 32020
(D) 100
6.8 A database table T1 has 2000 records and occupies 80 disk blocks. Another table T2 has 400
records and occupies 20 disk blocks. These two tables have to be joined as per a specified join
condition that needs to be evaluated for every pair of records from these two tables. The memory
buffer space available can hold exactly one block of records for T1 and one block of records for T2
simultaneously at any point in time. No index is available on either table.
If, instead of Nested-loop join, Block nested-loop join is used, again with the most appropriate choice
of table in the outer loop, the reduction in number of block accesses required for reading the data will
be
GATE | Gate IT 2005 | Question 85
Q82_Part B
(A) 0
(B) 30400
(C) 38400
(D) 798400