DBMS
DBMS
Total Marks : 20
Question 1
Look at the following truth table
A B A op B
F F T
F T F
T F F
T T F
a) ¬ A ∨ B
b) ¬ (A ∨ B)
c) ¬ (A ∧ B)
d) ¬ A ∧ B
Answer: (b)
Explanation: The last column in the truth table shows that the result of the operation
is true (or false) when A and B is both false (or any of the true).
1
Question 2
Consider the following array of seven integers:
30, 15, 10, 40, 25, 20, 12
What will be the contents of this array after the 2nd pass of bubble sort (sorting from smallest
to largest)? Marks: 1 MCQ
Answer: (c)
2
Question 3
Identify the correct representation of the prefix expression of the given tree below.
Marks: 1 MCQ
a) ∗2 + 4 ∗ 6 + 8 9
b) 2 + 4 ∗ 6 ∗ 8 + 9
c) 2 4 + 6 8 9 + ∗∗
d) ∗ + 2 4 ∗ 6 + 8 9
Answer:(d)
3
Question 4
Consider a set X = { {a, b}, {c, d}, {e, f} }. What is the number of elements in the power set
of X?
Marks: 1 MCQ
a) 4
b) 8
c) 12
d) 16
Answer: (b)
Explanation: Number of elements in X is 3. Hence, the number of elements in its power set
is 23 . So, option (b) is correct.
4
Question 5
When an ODD decimal number is converted into a binary number, what will be the the Least
Signaficant Bit(LSB)?
Marks: 1 MCQ
a) 0
b) 1
c) either 0 or 1
d) only 11
Answer: (b)
Explanation: If any odd decimal number is divided by 2, the remainder is 1 . This re-
mainder will be the LSB of the binary equivalent. So, LSB of binary represenation of any odd
decimal number will be always 1.
So, option b) is correct.
5
Question 6
Consider the following arrays of numbers. Which one represents a min-heap?
Marks: 1 MCQ
a) 20 5 15 10 6 8 9
b) 20 10 15 5 6 8 9
c) 9 6 10 8 5 15 20
d) 5 6 10 8 9 15 20
Answer: (d)
Explanation: According to the definition of the min-heap, any parent in a complete binary
tree, must be lesser than both its children.
Hence, option (d) is correct.
6
Question 7
Consider two sets A and B. Which of the following statement is are true?
Marks: 1 MSQ
a) A - B = A ∩ B
b) A - B = A - (A ∩ B)
c) A ∩ B = A ∪ (A ∩ B)
d) A ∩ B = A ∩ (A ∩ B)
Answer: b), d)
Explanation: If we draw Venn Diagram, we shall see that the statement in option (b) and
(d) are correct.
7
Question 8
Let a given function be f: I→ I given by f (x) = x2 where I stands for the set of all integers.
Which of the following statements is/are true?
Marks: 1 MCQ
Answer: (d)
Explanation: By the given function, f(-1)=1 and f(1)=1. Hence it is not one-one. f(x)should
always be a positive integer but. f: I → I. Consider a negative integer in the co-domain. There
is no value of x for which f(x) can be a negative integer.
8
Question 9
Consider the following:
CSE(x): The girl x is in CSE department.
NLP(x): The girl x studies NLP.
Which of the following formula represents “Not all CSE students study NLP.”
Marks: 1 MCQ
Answer: (d)
Explanation: The first option is ∀(x) (CSE(x) ∧¬NLP(x)). This is equivalent to ∀(x)¬((CSE(x) →
NLP(x)). That means CSE girls do not study NLP.
The second option states that if the girl is not in CSE, she studies NLP.
The third option states that some not CSE girls studies NLP.
The fourth option states that not all CSE girls study NLP.
Hence, option (d) is correct.
9
Question 10
Consider the binary relation S1 = {(1, 1), (2, 2), (1, 2), (2, 1)} on the set {1, 2}. Identify the
correct statement. MSQ, Mark 1
a) S1 is reflexive.
b) S1 is symmetric.
c) S1 is not transitive.
d) S1 is antisymmetric.
Answer: a), b)
Explanation: S1 reflexive, symmetric and transitive.
S1 is not antisymmetric as both (1, 2) and (2, a1) are present in S1
10
Question 11
What is the domain of the following function if the range is the set of real numbers?
5
√
x2 − 9
MCQ, Mark 1
b) (-∞, 3) ∪ (3, ∞)
d) (-3, 3)
Answer: c)
Explanation: The denominator is positive if x is not between -3 and +3. Hence, (c) is
correct.
11
Question 12
How many functions are there from the set {1, 2, 3} to the set {a, b}?
MCQ, Mark 1
a) 9
b) 8
c) 6
d) 5
Answer: b)
Explanation: The element “1” can be mapped to any of the two elements in the range.
Similarly, the element “2” or “3” can be mapped to any of the two elements in the range.
Hence, (b) is the correct option.
12
Question 13
If U is the set of integers excluding zero, V is the set of even integers, and D is the set of odd
integers, which of the following statement(s) is (are) true. Note: Here E denotes complement
over the expression E. U is the Universal set
MSQ, Mark 1
a) V ∪ D = U
b) U - V = D
c) V̄ = D
d) V - D = {0}
Answer: b), c)
Explanation: Follow the definition of universal set and difference operation.
13
Question 14
Suppose that A and B are two sets. Which of the following is always equivalent to A ∩ B
MSQ, Mark 1
a) (A − B) ∪ (B − A) ∪ (A ∩ B)
b) (A − B) ∪ (B − A)
c) A − (A − B)
d) B − (B − A)
Answer: c), d)
Explanation: As per the properties set operations, options (c) and (d) are correct.
14
Question 15
Consider the following function from {a,b,c,d} to {1,2,3,4,5}.
{(a,2), (b,1), (c,3), (d,4)}
Which of the following is true about the function?
MCQ, Mark 1
Answer: b)
Explanation: The function is one to one but not onto. Hence, option (b) is correct.
15
Question 16
Numbers 1, 2, 3, 4 are pushed into a stack in that order but these four PUSH operations are
intermixed with POP operations as well. Whenever a number is popped, it is printed. Which
of the following permutation can be printed by such PUSH and POP operations?
MCQ, Mark 1
a) 3, 4, 1, 2
b) 1, 4, 2, 3
c) 4, 2, 3, 1
d) 3, 2, 4, 1
Answer: d)
Explanation: If 3 is printed first, 1, 2 are in the stack. Next, 4 is pushed and popped. But
1 cannot be popped now. Hence (a) is not possible.
1 is pushed and popped. Then, 4 is printed. So, 2, 3 are in the stack. 2 cannot be popped
now. Hence (b) is not possible.
If 4 is printed first, 1, 2, 3 are in the stack. 2 cannot be popped now. Hence (c) is not possible.
If 3 is printed first, 1, 2 are in the stack. Next, 2 is popped. Then, 4 is pushed and popped.
Lastly, 1 is popped. Hence (d) is the correct option.
16
Question 17
Which one of the following is the most appropriate logical formula to represent the statement?
“Red and Yellow cars are beautiful”.
The following notations are used:
R(x): x is a Red car
Y(x): x is a Yellow car
B(x): x is beauiful
Note: ∀x denotes for all x. ∃x denotes for some x (atleast 1).→ denotes implication. ∨ and ∧
denotes OR and AND operation respectively.
MCQ, Mark 1
Answer: c)
Explanation: This statement can be expressed as
For all x, if x is either a red car or yellow car then the car x is beautiful.
Hence, option (c) is correct.
17
Question 18
Consider a B+-tree of order 5. What is the minimum number of children a root node can have,
considering it is not the only node in the tree?
MCQ, Mark 1
a) 5
b) 6
c) 2
d) 1
Answer: c)
Explanation: As per the construction rule of B+ tree, option (c) is correct.
18
Question 19
A hash table with length of 10 elements use open addressing with hash function h(k)=k mod
10, and linear probing. the table shows the state after insertion of 6 values. Identify a possible
order in which the key values could have been inserted in the table.
0
1
2 22
3 43
4 14
5 62
6 96
7 103
8
9
MCQ, Mark 1
Answer: d)
Explanation: In option a), 96 is placed at 6th index in the hash table. 22 is placed at 2nd
index. 14 is placed at 4th index.When 62 is going to be placed in 2nd index, there is a collision.
Therefore, 62 is placed at 3rd index.Hence, option (a) is not correct.
In a similar way, we can check for other options as well. We shall see that option (d) is correct.
19
Question 20
How many comparisons does it take to find the element 10 in the sorted array A = {10,15,17,19,20}
using binary search? MCQ, Mark 1
a) 2
b) 3
c) 5
d) 6
Answer: a)
Explanation: Using binary search technique:
First comparison with mid = 17
Second comparison with mid = 10 (this is the key).
Hence, option (a) is correct.
20
Database Management System: Assignment 1
Total Marks : 20
Question 1
Marks: 2 MCQ
Consider the SQL statement(s) below:
S1:
S2:
Answer: c)
Explanation: As per the Syntax of the language option (c) is the correct answer. DDL(Data
Definition Language) includes CREATE, DROP, ALTER, TRUNCATE, RENAME; DML(Data
Manipulation Language) includes INSERT, UPDATE, DELETE. For more details refer Module
2.
1
Question 2
Marks: 2 MCQ
Identify the valid primary key for the relation students.
students
student id students name address dept name
10001 ROHAN PUNJAB BENGALI
10002 KARTIKA BIHAR PHYSICS
10003 ANINDITA MUMBAI HISTORY
10004 ROHAN PUNJAB CHEMISTRY
10001 PANKAJ ASSAM CHEMISTRY
10004 SUHANA KERALA GEOGRAPHY
a) student id
b) student name
Answer: d)
Explanation: A primary key needs to identify each record in a table uniquely. So, op-
tion d) is the correct option. Other options are incorrect as these attributes do not identify
each tuple uniquely.
2
Question 3
Marks: 2 MSQ
Identify the correct statement/s.
Answer: a), d)
Explanation: Logical schema define the overall logical structure of the database.
Physical schema define the overall physical structure of the database.
View schema define the interaction between end-user and database.
Hence, options (a) and (d) are correct.
3
Question 4
Marks: 2 MCQ
b) {MountainName, StateName}
c) {MountainName, Altitude}
d) {MountainName}
Answer: d)
Explanation: Minimal superkeys are candidate keys. Here, MountainName alone is a su-
perkey, hence, any superset of MountainName will also be a superkey. But only MountainName
can be a candidate key.
Hence, (d) is the correct option.
4
Question 5
Marks: 2 MCQ
Let students(student id, student name, address, emailid ) and
enrolment(student id, dept name, enrolment date) be two relations in a schema.
The primary keys are shown underlined.
Let student id be a foreign key in enrolment relation referring to students relation. Suppose,
there is no violation of the above referential integrity constraint in the corresponding relation
instances of students and enrolment.
Which one of the following relational algebra expressions would necessarily produce an empty
relation?
Q Q
a) − student id (students)
student id (enrolment)
Q Q
b) student id (students) − student id (enrolment)
Answer: a)
Explanation:
Q According Qto the foreign key concept:
Q id (students) ≥ student
student Q id (enrolment).
So, student id (enrolment) − student id (students) = ϕ.
Hence, option (a) is the correct answer.
5
Question 6
Marks: 2 MSQ
Which of the following statements is (are) correct?
b) View level abstraction hides details of data types and focuses on the interaction with the
end-users.
c) Logical level abstraction describes what data is stored in a database and their relationships.
d) Physical level abstraction describes what data is stored in a database and their relationships.
Answer: b), c)
Explanation: As per the lecture notes (Module 02: Introduction to DBMS/1).
Physical level: describes how a record is stored.
Logical level: describes data stored in the database, and the relationships among the data.
View level: application programs hide details of data types.
Hence, options (b) and (c) are correct.
6
Question 7
Marks: 2 MCQ
Consider the following instance of the StudentDetails(StudentID, Student name) relation:
StudentID Student name
101 Priya
102 Shreya
If StudentID is the foreign key in the relational schema ExamResults(ExamID, CourseName,
StudentID), which of the following is a valid instance of ExamResults?
Answer: d)
Explanation: Option (a) is incorrect because StudentID “106” is not present in the refer-
enced relation StudentsDetails.
Option (b) is not correct because it is violating the primary key rules, as two tuples can not
have the same ExamID values.
Option (c) is not correct because primary key values must be unique and not NULL. But, first
tuple of, in ExamID values is NULL. That is not allowed.
Hence, option (d) is the correct answer.
7
Question 8
Marks: 2 MCQ
Consider the following tables:
ChatDetails1 ChatDetails2
SenderID ReceiverID Total Text SenderID ReceiverID Total Text
R001 S001 1000 R001 S001 1000
R002 S003 1200 R002 S003 1200
R001 S002 500 R004 S002 1500
R003 S004 700 R003 S003 1700
R004 S005 1400 R004 S001 1800
Identify the correct operation(s) which will produce the following output from the above two
relations.
a) ChatDetails1 − ChatDetails2
b) ChatDetails2 − ChatDetails1
Answer: d)
Explanation: As per Relational Operators syntax and semantics, option d) is correct.
8
Question 9
Marks: 2 MCQ
Consider the following table:
ChatDetails
SenderID ReceiverID Total Text
R001 S001 1000
R002 S003 1200
R001 S002 500
R003 S004 700
R004 S004 1400
Identify the correct operation(s) which produces the following output from the above relation.
ChatDetails
SenderID ReceiverID Total Text
R001 S001 1000
R002 S003 1200
R004 S004 1400
Answer: b)
Explanation: As per Relational Operators syntax and semantics, option b) is correct.
9
Question 10
Marks: 2 MCQ
Consider the following table:
ChatDetails
SenderID ReceiverID Total Text
R001 S001 1000
R002 S003 1200
R001 S002 500
R003 S004 700
R004 S004 1400
Identify the correct operation(s) which produces the following output from the above relation.
ChatDetails
SenderID ReceiverID
R002 S003
R004 S004
Answer: c)
Explanation: As per Relational Operators syntax and semantics, option c) is correct.
10
Database Management System: Assignment 2
Total Marks : 20
July 1, 2024
Question 1
Marks: 2 MCQ
ChatDetails
SenderID ReceiverID Total Text
R001 S001 1000
R002 S003 1200
R001 S002 500
R003 S004 700
R004 S004 1400
For the instance, the Total Text values need to be updated to increase by 500 for those
entries whose current values are less than 1000. What is the correct SQL Query for updating
the current instance?
Answer: b)
Explanation: For updating a particular field, the UPDATE clause is used in SQL The correct
command is given below:
UPDATE Tablename
SET column1 = value1, column2 = value2, column3 = value3,....
WHERE condition;
1
Question 2
Marks: 2 MCQ
ChatDetails
UserDetails
SenderID ReceiverID Total Text
SenderID Address
R001 S001 1000
R001 Kolkata
R002 S003 1200
R002 Delhi
R001 S002 500
R003 Kolkata
R003 S004 700
What is the output of the following SQL Query?
SELECT COUNT(Address) FROM ChatDetails, UserDetails GROUP BY Address;
a) 4
3
b) 4
8
c) 4
d) 3
Answer: b)
Explanation: The cartesian product (SELECT * FROM ChatDetails, UserDetails;) between
the 2 instances produce the following result:
COUNT() on Address with GROUP BY Address will return 4, 8 for the respective counts of
‘‘Delhi" and ‘‘Kolkata".
Hence, option (b) is correct.
2
Question 3
Marks: 2 MCQ
UserDetails
SenderID Address
R001 Kolkata
R002 Delhi
R003 Kolkata
R004 Kerala
R005 Agartala
R006 Mumbai
Which of the options will not be present in the output generated by the SQL query:
SELECT Address FROM UserDetails WHERE Address LIKE ‘%a’ OR Address LIKE ‘M%’ ;
a) Agartala
b) Kolkata
c) Mumbai
d) Delhi
Answer: d)
Explanation: The operator like uses patterns that are described using two special characters:
percent ( % ) and The underscore ( ). The % character matches any substring. The
character matches any character.
The clause WHERE Address LIKE ‘%a’ matches address ‘Kolkata’, ‘Kerala’ , ‘Agartala’. The
clause Address LIKE ‘M%’ matches with address ‘Mumbai’.
Hence, the option (d) is the correct answer.
3
Question 4
Marks: 2 MSQ
Which of the following statements is incorrect?
Answer: a), c)
Explanation: ALTER command allows addition or deletion or modification of attributes in a
relation.
DROP command allows deletion of relations.
DELETE command allows deletion of data.
Hence, options (a) and (c) are the correct answer.
4
Question 5
Marks: 2 MCQ
Consider the two instances:
ChatDetails
UserDetails
SenderID ReceiverID Total Text
SenderID Address
R001 S001 1000
R001 Kolkata
R002 S003 1200
R002 Delhi
R001 S002 500
R003 Kolkata
R003 S004 700
Which of the following operations will generate the output given below:
Answer: d)
Explanation: An EQUI JOIN is a join where the join condition contains an equality operator.
An EQUI JOIN returns only the rows that have equal values for the specified column(s) and
the compared column(s) twice.
The NATURAL JOIN automatically detects that both tables have a column named SenderID. It
joins the tables on the SenderID column and eliminates one of the duplicate SenderID columns
from the output.
Hence, option (d) is the correct answer.
5
Question 6
Marks: 2 MCQ
Consider the following instance of MountainDetails(MountainName,Altitude,StateName)
relation.
MountainDetails
MountainName Altitude StateName
Kangchenjunga 8586 Sikkim
Kabru 7338 Sikkim
Pandim 6888 Sikkim
Nanda Devi 7816 Uttarakhand
Trisul 7120 Uttarakhand
Kamet 7756 Uttarakhand
Sandakfu 3636 West Bengal
What will be the output of the following query?
MountainName Altitude
Kangchenjunga 8586
a)
Nanda Devi 7816
Sandakfu 3636
MountainName Altitude
Pandim 6888
b)
Kamet 7756
Sandakfu 3636
MountainName Altitude
c)
Kangchenjunga 8586
MountainName Altitude
d)
Sandakfu 3636
Answer: a)
Explanation: The SQL query selects the MountainName and Altitude from the Mountain-
Details table where the Altitude is equal to the maximum Altitude for each StateName.
Hence, option a) is correct.
6
Question 7
Marks: 2 MCQ
Consider the following instance of MountainDetails(MountainName,Altitude,StateName)
relation.
MountainDetails
MountainName Altitude StateName
Kangchenjunga 8586 Sikkim
Kabru 7338 Sikkim
Pandim 6888 Sikkim
Nanda Devi 7816 Uttarakhand
Trisul 7120 Uttarakhand
Kamet 7756 Uttarakhand
Sandakfu 3636 West Bengal
What will be the output of the following query?
MountainName Altitude
a) Kangchenjunga 8586
Nanda Devi 7816
MountainName Altitude
Kangchenjunga 8586
b)
Nanda Devi 7816
Kamet 7756
MountainName Altitude
c)
Kangchenjunga 8586
MountainName Altitude
d)
Nanda Devi 7816
Answer: c)
Explanation: The SQL query selects the MountainName and Altitude from the Mountain-
Details table whose Altitude is greater than the maximum Altitude found among mountains
in the state of “Uttarakhand”.
Hence, option c) is the correct answer.
7
Question 8
Marks: 2 MCQ
Consider the following instance UserDetails of a messenger application:
UserDetails
SenderID ReceiverID Total Text Address
R001 S001 1000 Kolkata
R002 S003 1200 Delhi
R001 S002 500 Kolkata
R003 S004 700 Kolkata
R004 S004 1700 Mumbai
UserDetails
SenderID ReceiverID Total Text Address
R002 S003 1200 Delhi
R004 S004 1700 Mumbai
Answer: b)
Explanation: Output table containing tuples whose Address is either Delhi or Mumbai. The
IN operator allows to specify multiple values in a WHERE clause.
Hence, option b) is correct.
8
Question 9
Marks: 2 MCQ
Consider the following instance UserDetails of a messenger application:
UserDetails
SenderID ReceiverID Total Text Address
R001 S001 1000 Kolkata
R002 S003 1200 Delhi
R001 S002 500 Kolkata
R003 S004 700 Kolkata
R004 S004 1700 Mumbai
Identify the correct statement to create an index on SenderID and Address of UserDetails
relation named as ‘View UserDetails’
a) Create View_UserDetails
AS UserDetails(SenderID, Address);
Answer: c)
Explanation: The general syntax to create any INDEX is
9
Question 10
Marks: 2 MCQ
Consider the following instance UserDetails of a messenger application:
UserDetails
SenderID ReceiverID Total Text Address
R001 S001 1000 Kolkata
R002 S003 1200 Delhi
R001 S002 500 Kolkata
R003 S004 700 Kolkata
R004 S004 1700 Mumbai
Identify the correct statement to find the SenderID, ReceiverID, and Address of UserDetails
table whose Total Text is in between 700 and 1200.
Answer: d)
Explanation: The BETWEEN operator selects values within a given range. The values can be
numbers, text, or dates and begin and end values are included.
The correct syntax to use BETWEEN opeartor is:
SELECT columnname(s)
FROM tablename
WHERE columnname BETWEEN value1 AND value2;
The IN operator allows you to specify multiple values in a WHERE clause. The IN operator
is a shorthand for multiple OR conditions.
Hence, option d) is correct.
10
Database Management System: Assignment 3
Total Marks : 20
Question 1
Marks: 2 MSQ
Identify the cases below in which a trigger is not preferred to use.
Answer: a), c)
Explanation: Databases provide better built-in support for replication, and risk of unin-
tended execution of triggers, can be possible at the time of loading data from a backup copy.
Hence, options a) and c) are the answer.
1
Question 2
Marks: 2 MCQ
Identify the correct Embedded SQL queries for the following:
Find the names of all students whose marks are between min marks and max marks
where min marks and max marks are declared in the host language.
a) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM students
WHERE marks BETWEEN :min_marks AND :max_marks
END_EXEC
b) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM students
WHERE :marks BETWEEN min_marks AND max_marks
END_EXEC
c) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM students
WHERE marks > :min_marks AND marks < :max_marks
END_EXEC
d) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM students
WHERE marks BETWEEN min_marks AND max_marks
END_EXEC
Answer: a)
Explanation: min marks and max marks are the variables of the Embedded SQL host
language which contains the values of the minimum and maximum marks. We use these
variables to find the names of the students whose marks are between the range with the
help of between construct. Variables of the host language must be preceded by a colon (:) to
distinguish from SQL variables. Hence, option (a) is correct.
2
Question 3
Marks: 2 MCQ
Consider the following Entity Relationship Diagram:
Answer: a)
Explanation: As per the syntax and semantics of ER diagram, composite attributes are
flattened out by creating a separate attribute for each component attribute.
Hence, option a) is correct.
3
Question 4
Marks: 2 MCQ
Consider the following instance of the relation FlowerShop(Name, Location, OpensAt, ClosesAt,
KnownFor)
FlowerShop
Name Location OpensAt ClosesAt KnownFor
Bageecha Delhi 10am 6pm Orchids
FloralParadise Delhi 10am 7.30pm Sunflower
TreeLand Mumbai 1pm 10pm Anthuriums
TreeLand Mumbai 1pm 10pm Hyacinths
FloralParadise Pune 8am 11pm Celosia
Answer: b)
Explanation: Options (a) and (c) are incorrect as the common attributes for the Natural Join
do not have a common value for any tuple produced by R1 and R2 . Option (d) is incorrect as
it produces the tuple FloralParadise Sunflower Pune .
Hence, option (b) is correct.
4
Question 5
Marks: 2 MCQ
Consider the following scenario:
An Environmental resource management company keeps record of different forests, identified
by their names. A forest is associated with its location that contains the country and area
in which the forest is present. In each forest, there are different types of trees that are also
recorded by the company.
Which of the following schema correctly represents the Forest entity set?
Answer: d)
Explanation: In the schema of option (a), the location is not properly explained.
In the schema of option (b), if the attribute Name will be the primary key, only one Tree type
can be stored in the Forest relation.
In the schema of option (c), types of Trees are not reflected in the Forest relation.
The schema in option (d) specifies the location correctly and captures the tree information in
a forest as well.
Hence, option (d) is correct. Refer to slide 14.23 for details.
5
Question 6
Marks: 2 MCQ
Consider the following instance of the relation Gardens(Name, Location, OpensAt, ClosesAt,
KnownFor)
Gardens
Name Location OpensAt ClosesAt KnownFor
Bageecha Delhi 10am 6pm Orchids
FloralParadise Delhi 10am 7.30pm Sunflower
TreeLand Mumbai 1pm 10pm Anthuriums
TreeLand Mumbai 1pm 10pm Hyacinths
FloralParadise Pune 8am 11pm Celosia
a) TreeLand
Mumbai Anthuriums
b)
Mumbai Hyacinths
Anthuriums
d)
Hyacinths
Answer: d)
Explanation: According to the syntax and semantics of Tuple Relational Calculus, option
(d) is correct.
6
Question 7
Marks: 2 MSQ
Consider the following Entity Relationship Diagram:
c) Lead and Background entity sets are disjoint specializations of Singer entity set.
d) Lead and Background entity sets are Overlapping specializations of Singer entity set.
Answer: b), c)
Explanation: In an ER diagram, double lines between entity and relation represent total
relationship.
Entities connected by one arrowhead to another entity represents disjoint specialization.
Thus, options (b) and (c) are correct.
7
Question 8
Marks: 2 MCQ
An entity in CUSTOMER entity set is associated with at most one entity in LOAN set. An entity
in LOAN, however, can be associated with any number (zero or more) of entities in CUSTOMER.
What is the cardinality of the relation between LOAN and CUSTOMER?
a) One-to-many
b) One-to-one
c) Many-to-many
d) Many-to-one
Answer: a)
Explanation: Here one entity in LOAN set is related to more than one entity in CUSTOMER
set. Hence, it is a one-to-many relationship.
8
Question 9
Marks: 2 MSQ
Consider the instance of the relational schema DOCTORS(DrID, Name, Specialization):
DOCTORS
DrID Name Specialization
A12 J.Ray Heart
A187 J.Ray Child
B3 KatieP Kidney
H23 L.Houston Heart
Which of the following Relational Algebra expressions produce(s) exactly the same tuples as
present in this instance of DOCTORS?
Answer: a), d)
Explanation: Option (b) is incorrect as it produces 2 extra tuples due to the redundant value
J. Ray in the common attribute.
Option (c) is incorrect as Name will not be present in the output.
Options (a) and (d) are correct.
9
Question 10
Marks: 2 MCQ
Consider the relation Tender(Tno, Price). Assume that there is a tuple (2, 20000) in the
given relation. Identify the final value of n after the execution of the following loop:
DECLARE
n NUMBER:= 0;
BEGIN
FOR r IN 1..5 LOOP
SELECT Price INTO n FROM Tender WHERE Tno=2;
n:= n+(r*2);
END LOOP;
END;
a) 20000
b) 20010
c) 20030
d) 100030
Answer: b)
Explanation: In each iteration, the value of n is reset due to the SELECT statement but the
value of r gets incremented.
In the last iteration, n = 20000, r = 5.
So, the final value of n = 20010.
Thus, option (b) is correct.
10
Database Management System: Assignment 4
Total Marks : 20
Question 1
Marks: 2 MCQ
Find the functional dependencies that stand valid on the part of the relation shown below:
P Q R
a 1 c
a 2 c
b 3 c
b 4 c
a) P→ Q, P → R
b) Q → P, P → R
c) Q → P, R → P, P → R
d) P → Q, P → R, R → P
Answer: b)
Explanation: P cannot uniquely determine Q, because for the same value of P multiple
values of Q are obtained. So P → Q is false. Options a) and d) are false hence.
R→ P is also false because unique value of R determines multiple values of P. So, option c)
is false.
Option b) is true because for unique values of Q, unique value of P is determined and unique
value of P determines unique value of R.
1
Question 2
Marks: 2 MCQ
Consider the relation Email(Sender, Receiver, Date, Time, Subject) with the following
functional dependencies.
FD1: {Receiver, Date}→Time
FD2: {Sender, Date}→{Receiver, Subject}
FD3: Receiver→Subject
a) 1 NF
b) 2 NF
c) 3 NF
d) BCNF
Answer: b)
Explanation: The primary key of the given relation is {Sender, Date}. in FD3, a non
prime attribute depends on another non prime attribute. Hence, option (b) is correct.
2
Question 3
Marks: 2 MCQ
Consider the relation Office(OID, Emp, Branch, Dept) with the following functional depen-
dencies:
FD1: {OID, Emp}→Branch
FD2: Branch→Dept
FD3: Dept→OID
How many candidate keys are there for the given relation?
a) 1
b) 2
c) 3
d) 4
Answer: c)
Explanation: The candidate keys of the given relation are {OID, Emp}, {Emp, Branch} and
{Emp, Dept}.
Hence, option (c) is correct.
3
Question 4
Marks: 2 MCQ
Consider the relation TICKET(PNR, DERARTURE, ARRIVAL, SEATNO, COACHNO) with the fol-
lowing functional dependencies.
FD1: {PNR, DEPARTURE}→ARRIVAL
FD2: ARRIVAL→SEATNO
FD3: {DEPARTURE, SEATNO}→COACHNO
Which of the following attributes cannot functionally determine COACHNO?
a) {ARRIVAL}
b) {PNR, DEPARTURE}
d) {DEPARTURE, ARRIVAL}
Answer: a)
Explanation: The closure of ARRIVAL contains {ARRIVAL, SEATNO} only. The closure of all
other given sets of attributes contain COACHNO.
Hence, option a) is the answer.
4
Question 5
Marks: 2 MCQ
Find the canonical cover of Relation R=(A, B, C) where F=(A→BC, B→C, A→B, AB→C)?
a) A→BC
b) A→B, B→C
c) A→B, AB→C
d) A→BC, AB→C
Answer: b)
Explanation: A→B and B→C determines A→C(transitivity). So, A→C and B→C determines
AB→C. Hence, the FD AB→C is redundant.
After removing AB→C, we have (A→BC, B→C, A→B).
Next, A→B and A→C determines A→BC(union). So, the FD A→BC is also redundant.
So, the canonical cover is (B→C, A→B). Hence, option b) is the answer.
5
Question 6
Marks:2 MSQ
Consider the following relational table FRUIT STORE:
FRUIT STORE
F ID F Name Category Price Owner
1281 Mango Uttar Pradesh 100 W. Hanna
1282 Apple Kashmir 200 C. Buck
1281 Mango Uttar Pradesh 120 X
1282 Mango West Bengal 150 K. Bhardwaj
1281 Banana Tamil Nadu 80 T. Park
If (F Name, Owner) is a key for this instance, what may be the value of X?
a) W. Hanna
b) C. Buck
c) W. Hanna or K. Bhardwaj
d) O. Kuzovkov
Answer: b), d)
Explanation: The value of X can be any Owner Name except W. Hanna or K. Bhardwaj for
(F Name, Owner) to be a key.
Hence, options b) and d) are valid.
6
Question 7
Marks: 2 MSQ
Consider a relation Customer(CID, NAME, ADDRESS) with the following functional dependen-
cies.
FD1: CID→NAME
FD2: NAME→ADDRESS
The current instance of this schema contains the tuple {121, Lucy, Delhi}.
Which of the following tuples can be inserted?
Answer: a), b)
Explanation: CID is the key and should be uniquely identifying NAME. So, {CID, NAME}
cannot be {121, Jenny} in the new tuple. So, option d) is invalid.
Since NAME uniquely identifies ADDRESS, Lucy cannot be associated with any other ADDRESS
except Delhi. So, option c) is invalid.
Hence, options a) and b) are correct.
7
Question 8
Marks:2 MCQ
The relation R(A,B, C, D, E, F, G) with the functional dependencies: { A → B, A → C, AE →
D, AEF → G } is normalised into BCNF.
Which of the following decomposition is obtained as a result of this normalisation?
Answer: b)
Explanation: Closure of AEF={A,B,C,D,E,F,G}. Thus, AEF is a candidate key. From
the given FDs, we see that there are partial dependencies in A → B , A → C and AE → D.
To normalise them, the correct decomposition is R1 (A, B, C), R2 (A, E, D), R3 (A, E, F, G).
These tables are also in BCNF.
Hence, option b) is correct.
8
Question 9
Marks:2 MCQ
Consider a relation STUDENT(Name, Subject, Location, Marks).
1. STU SUB (Name, Subject, Location) and STU LOC(Name, Location, Marks)
Answer: d)
Explanation: Decomposition 1) is lossy as Join operation between the tables does not return
the table which is same as STUDENT.
Decomposition 2) is lossy as there is no common attribute between the decomposed relations.
Hence, option d) is correct.
9
Question 10
Marks: 2 MCQ
Consider the relation DVDLibrary(Name, Company, Format, Price) with the following Func-
tional Dependencies:
FD1: {Name, Company} → {Format, Price}
FD2: Company → Format
FD3: Format → Price
Which of the following statements is (are) true?
b) DVDLibrary is in 2NF.
Answer: c)
Explanation: Option (a) is false because the primary key is {Name, Company}.
Option (b) is false because partial dependency is there.
Option (d) is false as the decomposition is lossless.
Option (c) is true as the given decomposition, does not preserve functional dependencies.
Hence, option c) is correct.
10
Database Management System: Assignment 5
Total Marks : 20
Question 1
Marks: 2 MCQ
Which of the following protocol(s) is used by a web server to communicate with external
applications?
a) HTTP
b) SMTP
c) TCP/IP
d) CGI
Answer: d)
Explanation:
Common Gateway Interface(CGI) is a standard interface between web and application server.
(Refer Lecture-21).
So, option (d) is correct.
1
Question 2
Marks: 2 MCQ
In which way does an audit trail help to ensure the security of a system?
Answer: d)
Explanation:
An audit trail is used to record the history of operations performed on a file. From it, we can
come to know which user updates or accesses some sensitive data, or does a delete operation,
etc. So, audit trails can be used later on if the need arises to detect security breaches.
(Refer Lecture slide 22)
So, option d) is correct.
2
Question 3
Marks: 2 MCQ
Suppose, there is a disk with 200 sectors per track, size of one sector is 512 bytes and one
disk block unit is 4 kilobytes. What will be the access time of a single block unit if its average
seek time and rotational speed is 6 ms, and 12000 RPM. respectively, assuming the data rate
is 128 kilobytes per second?
a) 42.25 ms
b) 39.75 ms
c) 31.25 ms
d) 14.125 ms
Answer: b)
Explanation: There are three components of any disk access. Those are - seek time,
rotational delay and transfer time.
Rotational speed = 12000 RPM. Thus, the time for one rotation is
60 seconds/12000 rotations = 5ms per rotation.
Now, average rotational delay = 12 * Time of one rotation in milliseconds.
So, average rotational delay is 1/2 * 5ms = 2.5 ms.
One block unit is 4KB. Thus, the transfer time is = 4KB / 128KB = 0.03125 sec = 31.25 ms
Thus, the total disk access time = one seek + average rotational delay + block transfer time
= 6ms + 2.5ms + 31.25 ms = 39.75 ms
So, option b) is correct.
3
Question 4
Marks: 2 MCQ
If mean time to failure(MTTF) of a disk system is 60 days and it will take 20 hours to repair
the system. What is the availability of the disk system?
a) 13.89%
b) 75.1%
c) 98.63%
d) 100%
Answer: c)
Explanation:
Mean time to failures is not the average time that the system is working and then failing. It
is the average time between failures.
Mean time to failures (MTTF) = total uptime / number of failures.
Mean time to repair is the average time taken to repair the system after failure.
Mean time to repair (MTTR) = total down time/number of failures.
Availability = Total uptime / (total uptime + total downtime)
= MTTF/(MTTF+MTTR)*100
= 60*24/(60*24 + 20) *100
= 1440/(1440+20)
= 98.63 %
So, option (c) is correct.
4
Question 5
Marks: 2 MCQ
Suppose there is a 256 gigabyte flash storage system, with a four kilobyte page size. What will
be the size of the page address if the flash translation table is 512 megabytes long, and the
table is stored as an array?
a) 128 bits
b) 64 bits
c) 32 bits
d) 16 bits
Answer: b)
Explanation: Number of pages = 256 gigabyte/4 kilobyte =(256 ∗ 230 )/(4 ∗ 210 ) = 64*220
Say, require bits to address one page is = N
The flash translation table size = 512 megabytes
N = (Flash translation table size)/(Number of pages)
=(512*220 )/(64*220 ) bytes=8 bytes =64 bits.
Hence, option b) is correct.
5
Question 6
Marks: 2 MCQ
In an IoT demonstration competition, students can enroll their names as a team member.
There can be two or more members in a team but one member can enroll his/her name only for
one team. Each team has a unique id and name. Each member has a unique id and name too.
Which of the following way(s) is/are correct for storing the information of members and teams?
a) We may create one table Team with Team Id as primary key and a table Members with
Mem Id as primary key. In the second table, column Team Id will be added as a foreign key.
b) We may create one table Members with Mem Id as primary key and a table Team with
Team Id as primary key. In the second table, column Mem Id will be added as a foreign key.
c) No foreign key will be required only Members and Team table is enough.
Answer: a)
Explanation: There will be a one-to-many relationship between Team and Members. An
one-to-many relationship can be designed with two tables.
Create one table Team with Team Id as primary key and a table Members with Mem Id as
primary key and in Members table add column Team Id as foreign key.
6
Question 7
Marks: 2 MCQ
Redundant Arrays of Independent Disks use the technique of redundancy to avoid data and
information loss in case of disk failure. Which of the following technique(s) is used for data
duplication?
a) Compressing
b) Interleaving
c) Striping
d) Mirroring
Answer: d)
Explanation: The simplest technique to introduce redundancy is to duplicate every disk.
This process is known as Mirroring.
hence, option d) is correct.
7
Question 8
Marks: 2 MCQ
Suppose that a disk drive has 200 tracks, numbered 0 to 199. The queue of pending requests
in SSTF order is: 72, 122, 84, 175, 48, 150, 102, 181, 145.
The read-write head initially is on track 65. What is the total distance that the disk head
will move to satisfy all pending requests following Shortest Seek Time First (SSTF) scheduling
algorithms?
a) 538
b) 343
c) 249
d) 150
Answer: c)
Explanation: Disk head will move from 65 to: 72, 84, 102, 122, 145, 150, 175, 181, and last
48. So, the total movement will be (181-65) + (181-48) = 116+ 133 = 249
So, option c) is correct.
8
Question 9
Marks: 2 MCQ
Consider a relation course(c id, dno, subject, cname, dname, semester, year, building)
c id → cname, subject
dno → dname, building
c id, subject → year, semester
If we perform a schema refinement on course, which of the following set of relations will be
in the refined schema?
Answer: b)
Explanation: In options a), c) and d), there are no common attributes between courseDept
and course, to rejoin the relations again to get the original table.
Option b) will return the original table after rejoining.
So, option b) is correct.
9
Question 10
Marks: 2 MSQ
Which of the following statement(s) is (are) correct?
a) The disk controller acts as an interface between the computer system and the disk drive
hardware.
b) Mean time to failure (MTTF) is the minimum time, when a disk can run continuously
without any failure.
c) When a sector is found to be bad, the disk controller remaps the logical sector to a different
physical sector.
d) When a huge number of disks are connected by a high-speed network to a number of servers,
is called Network Area Storage.
Answer: a), c)
Explanation: Mean time to failure (MTTF) is the average time, when a disk may run
continuously without any failure.
When a huge number of disks are connected by a high-speed network to a number of servers,
is called Storage Area Networks.
These two statements are incorrect.
Disk controller acts as an interface between the computer system and the disk drive hard-
ware.
When a sector is found to be bad, the disk controller remaps the logical sector to a different
physical sector.
So, these two statements are right.
Hence, options a) and c) are correct.
10
Database Management System: Assignment 6
Total Marks : 20
Question 1
Marks: 2 MSQ
Identify the incorrect statement(s) from the following.
a) In primary index, index entries can be stored in unsorted order of the search key value.
b) In a secondary index file, all the search key values must be presented.
Answer: a), c)
Explanation: secondary indices have to be dense. A Secondary index contains all key values
and each key value entry has a pointer to the record that contains the key value. And sequential
scan using a secondary index is expensive. So, options b) and d) are correct statement.
Whereas, in the primary index, index entries must be stored in sorted order of the search
key value. And the clustered index is built by default on unique key columns. So, options a)
and c) are incorrect.
Hence, options a) and c) are the answer.
1
Question 2
Marks: 2 MCQ
Which of the splitting rule is not correct in respect of 2-3-4 Tree?
a)
b)
c)
d)
Answer: d)
Explanation: Splittings corresponding to options (a), (b) and (c) are correct. Refer to slide
27.
In option (d), links are inserted incorrectly. So, option (d) is the answer.
2
Question 3
Marks: 2 MCQ
Consider a system that uses B+ tree for indexing its records. Calculate the order of a non-leaf
node, if the block size is 2 kilobytes, size of the search key field is 10 bytes, and the block
pointer size is 18 bytes?
a) 44
b) 73
c) 113
d) 204
Answer: b)
Explanation: A B+tree of order m means every node has at most m children.
So, there will be only m number of block pointers and (m − 1) number of key value in any
non-leaf nodes.
3
Question 4
Marks: 2 MSQ
A hash table contains 10 (indices 0 to 9) buckets and uses linear probing to resolve collisions.
The key values are integers and the hash function used is (key % 10). Given the follow-
ing input (543, 432, 741, 330, 471, 351, 170, 245), which of the following statement(s)
is/are true?
Answer: b), c)
Explanation: After inserting all keys, the buckets will be:
4
Question 5
Marks: 2 MCQ
Suppose, there is a DBMS file with size 16 kilobytes. Calculate the size of the index table, if
the size of one record is 64 bytes long which includes 10 bytes key field assuming the system
uses primary indexing and the record pointer is 48–bit long?
a) 1 kilobyte
b) 2 kilobytes
c) 3 kilobytes
d) 4 kilobytes
Answer: d)
Explanation: In primary indexing, one index entry contains key value and record pointer.
Hence, one index entry = size of one key + size of record pointer = 10 bytes + 6 bytes
Now, the file size = 16 KB
Size of one record = 64 bytes
So, number of entries in the index table = 16 KB ÷ 64 bytes=28
Size of the index table = 28 * 16 bytes = 4 KB
Hence, option d) is correct.
5
Question 6
Marks: 2 MCQ
Consider the following table Patient. If we want to create an index on PatID column, which
type of indexing will be preferred?
a) Sparse index
b) Dense index
c) Secondary index
d) Non-clustering index
Answer: b)
Explanation: When the file is not sorted on the indexed field or when the index file is small,
compared to the size of the memory, it is preferable to use dense indexing. The above table
has only 6 records and PatID field is not in sorted order.
Hence, option b) is correct.
6
Question 7
Marks: 2 MCQ
There is a 2-3-4 Tree as follows:
a) 11
b) 7
c) 4
d) 3
Answer: c)
Explanation: For finding 34, 4 comparisons will be required: first comparison with 36, second
comparison with 28, third comparison with 30 and the last comparison with 35. Then only it
can be said that the key is not found.
So, option (c) is correct.
7
Question 8
Marks: 2 MCQ
See the following B+ tree. Find the minimum number of nodes (including the root node) that
must be fetched in order to satisfy the following query:
“Find all the records greater than 5 and less than 17”
a) 4
b) 5
c) 6
d) 7
Answer: b)
Explanation: All the leaf nodes are connected with pointers in B+ tree. So first, we need
to search for key less than (if 5 does not present) or equal to 5. We start searching from the
root node and move to the node with key 5 and 14. As we need the value greater than 5, we
will move to the leaf node with 5. We will traverse and search the nodes upto the node having
key 17.
So, the total number of nodes fetched = 2 (for searching 5) + 3(for finding keys less than 17)
= 5.
So, option b) is correct.
8
Question 9
Marks: 2 MCQ
Consider a shop maintained a relation Order(Order No, ItemID, Quantity) for storing or-
der information. We have created a bitmap index on Order table and the size of the index
file is 512 bytes for 256 number of rows. How many different types of items are availble in the
shop assuming ItemID as the index column?
a) 16
b) 8
c) 4
d) 2
Answer: a)
Explanation: A bitmap index of N number of row with m distinct values in the index
column will have N x m bits in the bitmap.
So, the size of the index file will be (256 x m) bits = 512 bytes = 512*8 bits
So, m = (512 ∗ 8)/256 = 16 bits
Only 16 different types of items are available in that shop for order.
Hence, option a) is correct.
9
Question 10
Marks: 2 MCQ
Consider the following OrderTable:
OrderTable
Order no Cust id salesman id Amount
A001 1005 2 750
A009 3001 4 270
A002 3002 1 1500
B004 5001 3 2300
B007 1005 22 830
A005 6007 51 1100
... ... ... ...
For the OrderTable table, assume that there are 10 salesmen, and each salesman is associated
with a minimum of 500 orders. Suppose OrderTable is commonly queried as:
SELECT * FROM OrderTable WHERE Order no = ‘XXXX’ AND salesman id = Y;
For speeding up the execution of queries, it is decided to create an index on the table. Which
of the following query will create such an index?
Answer: c)
Explanation: Instead of creating a single column index, one can create a composite index
(using several columns), and the same index can be used for queries that reference all of these
columns, or just some of them.
The order of columns in the CREATE INDEX statement of composite index can affect
the performance. Put the column expected to be used most often first in the index.
Here, we have to create a composite index with the most selective (with most values
column Order no) first, salesman id next.
CREATE MULTI INDEX command is wrong.
So, option c) is correct.
10
Database Management System: Assignment 7
Total Marks : 20
Question 1
Marks: 2 MCQ
Consider the following schedule S of transactions T1 and T2 .
The read operation on data item A is denoted by read(A) and the write operation on data
item A is denoted by write(A).
T1 T2
read(A)
A:=A-1000
write(A)
read(A)
read(B)
B:=B+1000
temp:=A∗0.8
A:=A-temp
write(B)
write(A)
read(B)
B:=B+temp
write(B)
c) S is serializable only as T1 , T2 .
d) S is serializable only as T2 , T1 .
Answer: c)
Explanation: First, swap all non-conflicting instructions of the above schedule S.
T1 and T2 both are working on the same data items.
So, S is serializable as T1 , T2 only
Hence, option (c) is correct.
1
Question 2
Marks:2 MCQ
Consider the following schedule S involving five transactions T1 , T2 , T3 , T4 , and T5 :
T1 T2 T3 T4 T5
R(X)
W(X)
R(Y)
W(Y)
W(X)
W(Y)
R(Z)
W(Z)
W(Z)
Answer: c)
Explanation: If we draw the precedence graph of the transactions as shown in the fol-
lowing, we can observe that the graph has no cycle.
So, the above schedule is a conflict serializable schedule.
All conflict serializable schedules are view serializable too.
2
Question 3
Marks:2 MCQ
Consider the following schedule S involving four transactions T1 , T2 , T3 and T4 .
T1 T2 T3 T4
R(X)
W(X)
W(Z)
R(Z)
R(Z)
W(Z)
a) 1
b) 2
c) 3
d) 4
Answer: a)
Explanation: If we draw the precedence graph of the schedule, we can observe that the
graph has no cycle. Hence, the above schedule is conflict serializable schedules.
All possible topological orderings of the above precedence graph will be the possible
conflict serializable schedule.
1. T3→T4→T1→T2
Hence, option a) is correct.
3
Question 4
Marks:2 MCQ
Consider the following schedule S involving four transactions T1 , T2 , T3 and T4 .
T1 T2 T3 T4
R(X)
R(Z)
W(X)
R(Y)
W(Y)
W(X)
W(Y)
W(Z)
a) T1 → T3 → T2 → T4
b) T1 → T2 → T3 → T4
c) T3 → T1 → T2 → T4
d) T3 → T2 → T1 → T4
Answer: d)
Explanation: If we draw the precedence graph of the transactions as shown in the fol-
lowing, we can observe that the graph has no cycle.
So, the above schedule is a conflict serializable schedule.
All conflict serializable schedules are view serializable too.
All possible topological orderings of the above precedence graph will be the possible
conflict serializable schedule.
Hence, the correct order of execution of all transactions is:
1. T1 → T3 → T2 → T4
2. T1 → T2 → T3 → T4
3. T3 → T1 → T2 → T4
So, option (d) is the answer.
4
Question 5
Consider the following schedule S. Marks: 2 MCQ
T1 T2 T3
R(X)
R(Y)
W(Y)
R(Y)
W(Y)
W(X)
W(Y)
a) 7
b) 5
c) 3
d) 1
Answer: d)
Explanation: Step 1: Final Update on data item: Y-T1
Final Update on data item: X-T1
Since the final update on Y and X is made by T1, the transaction T1 must execute after all
the transactions: (T2,T3) → T1.
Step 2: Initial Read + Which transaction updates after read?
Y : T3 (initial read) then T2 firstly updates it.
Hence, the dependency is: T3 →T2
X : T3 (initial read) then T1 firstly updates it as well as final update also.
Hence, T1 will execute later than T3: T3 →T1
Step 3: Write Read Sequence: T2 firstly writes Y and then T1 reads Y.
Hence, the dependency is: T2 →T1
The ways we can arrange (T3→T2 → T1).
Hence, total possible view serializable schedule of S= 1.
Hence, option (d) is correct.
5
Question 6
Marks:2 MCQ
Consider two transactions given below where lock-X(A) denotes Ti has obtained an Exclusive-mode
lock on item A and lock-S(A) denotes Ti has obtained a Shared-mode lock on item A.
T1
lock-S(A)
T2
read(A)
lock-X(A)
lock-X(B)
read(A)
read(B)
A:= A-100
B:= B+100
write(A)
write(B)
lock-S(B)
lock-S(C)
read(B)
read(C)
commit
unlock(A)
unlock(A)
unlock(C)
unlock(B)
commit
unlock(B)
a) T2 follows the rigorous two-phase locking protocol, but T1 follows the strict two-phase
locking protocol only .
b) T1 follows the rigorous two-phase locking protocol, but T2 follows the strict two-phase
locking protocol only.
Answer: a)
Explanation: Transaction T1 first unlocks all Shared-mode lock and then commits. After
commit, it unlocks Exclusive-mode lock . That is why, it follows the strict two phase
locking protocol only.
Transaction T2 first commits and then unlocks all locks(Exclusive-mode lock and Shared-mode
lock). That is why, T2 follows the rigorous two-phase locking protocol.
So, option (a) is correct.
6
Question 7
Marks: 2 MSQ
Suppose in a database, there are four transactions T1 , T2 , T3 , and T4 with timestamp 10, 14, 18,
and 22 respectively. T2 is holding a data item which T1 and T3 are requesting to acquire. Which
of the following statement(s) is (are) correct in respect of Wound-Wait Deadlock Prevention
scheme?
Answer: b), c)
Explanation: Wound-Wait Deadlock Prevention scheme: When TA1 requests data item held
by TA2 (older means smaller timestamp), two cases may arise.
• If TA1 is older than TA2 then TA1 wounds TA2 (TA2 will be aborted).
• If TA1 younger to TA2 then TA1 will wait for release the data item held by TA2.
7
Question 8
Consider the following schedule S. Marks: 2 MCQ
T1 T2
R(X)
W(X)
R(Y)
W(Y)
R(X)
COMMIT
W(X)
R(Y)
W(Y)
COMMIT
Answer: a)
Explanation: Recoverable schedule: If a transaction Tj reads a data item previously written
by a transaction Ti , the commit operation of Ti must appear before the commit operation of
Tj .
Cascadeless schedules: For each pair of transactions Ti and Tj such that Tj reads a data item
previously written by Ti , the commit operation of Ti appears before the read operation of Tj .
Here, T2 read data item X before commit of T1 . Hence, the schedule is recoverable.
So, option (a) is correct.
8
Question 9
Consider the following schedule S. Marks: 2 MCQ
T1 T2 T3
R(X)
W(X)
R(Y)
commit
R(X)
W(X)
R(X)
W(X)
abort
a) If T2 fails (aborted), both transactions T1, and T3 must also be rolled back.
Answer: c)
Explanation: As per the cascading rollback a single transaction failure leads to a series of
transaction rollbacks.
Hence, if T2 fails (aborted), T1 must also be rolled back.
Transaction T3 has already been committed, so no rollback will happen. So, option (c) is
correct.
9
Question 10
Marks: 2 MCQ
Suppose that four transactions T1 , T2 , T3 and T4 are being applied on a database. Transaction
T1 is waiting for transactions T2 ; transaction T2 is waiting for transaction T3 , and
transaction T4 is waiting for transactions T1 and T2 to release a data item.
Identify the correct wait-for graph for the above scenario.
a)
b)
c)
d)
Answer: c)
Explanation: When Ti requests a data item currently being held by Tj , then the edge Ti
→ Tj is inserted in the wait-for graph. An edge Ti → Tj implies that Ti is waiting for Tj to
release a data item.
Hence, option c) is correct.
10
Database Management System: Assignment 8
Total Marks : 20
August 3, 2024
Question 1
Marks: 2 MSQ
Assume an immediate database modification scheme. Consider the following log records for
transactions T0, T1, T2, T3 and T4:
If there is a crash just after step 13 and the recovery of the system is successfully completed,
identify the correct action for the above scenario.
Answer: c), d)
Explanation: In the immediate database modification scheme, during recovery after a
crash, a transaction needs to be redone if and only if both ⟨Ti , start⟩, ⟨Ti , commit⟩ are
present in the log. Otherwise undo is required.
Any transactions that are committed before the last checkpoint should be ignored(updates
already output to disk due to the checkpoint).
Redo list contains transaction {T3} and undo list contain transactions {T1, T2, T4} and for
transaction {T0} no need any action because it is already committed before checkpoint.
As per the process of transaction recovery, options (c) and (d) are correct.
1
Question 2
Marks: 2 MCQ
Assume an immediate database modification scheme. Consider the following log records
for transactions T0, T1, T2, T3 and T4:
If there is a crash just after step 14 and the recovery of the system is successfully completed,
identify the correct action for the above scenario.
Answer: b)
Explanation: In the immediate database modification scheme, during recovery after a
crash, a transaction needs to be redone if and only if both ⟨Ti , start⟩, ⟨Ti , commit⟩ are
present in the log. Otherwise undo is required.
Any transactions that are committed before the last checkpoint should be ignored(updates
already output to disk due to the checkpoint).
Redo list contains transactions {T1, T3} and undo list contains transactions {T2, T4} and for
transaction {T0}, no action is needed because it is already committed before checkpoint.
Hence, option b) is the answer.
2
Question 3
Marks:2 MCQ
Identify the cost estimation of a query evaluation plan, if 10000 blocks are required to
transferred from the disk and the required number of disk seeks are 50.
a) 20.4 Seconds
b) 40 Seconds
c) 40.4 Seconds
d) 60 Seconds
Answer: d)
Explanation: Cost for b block transfers plus S seeks will be (b ∗ tT + S ∗ tS ) seconds
=(10000 ∗ 4 ∗ 10−3 ) + (50 ∗ 0.4) seconds
= (40 + 20) Seconds
= 60 Seconds
For more details refer to 38.12 of lecture material.
Hence, option d) is the answer.
3
Question 4
Marks:2 MCQ
Let us consider the following statistics for two relations Doctor and Appointment Details:
Let us consider a natural join of Doctor and Appointment Details relations (Doctor 1
Appointment Details).
Identify the required number of block transfers in the worst case (enough memory only to
hold one block of each relation) using Nested-loop join and assuming Doctor as the outer
relation.
Answer: d)
Explanation: Number of block transfers will be: 3000×10 + 30 = 30030, if Doctor is taken
as the outer relation.
For more details refer to 38.31 of lecture material.
4
Question 5
Marks:2 MCQ
Consider the following state of transactions and the statements below.
c) 1), 3), 5)
d) 1), 4), 5)
Answer: d)
Explanation: Any transaction that is committed before the last checkpoint should be ignored.
Therefore, T1 , T2 and T3 can be ignored (updates already output to disk due to the last
checkpoint).
Any transaction that is committed since the last checkpoint, needs to be redone. Hence, T4 is
to be redone.
Any transaction that was running at the time of failure, needs to be undone and restarted.
Hence, T5 , and T6 are to be undone.
Hence, option (d) is correct.
5
Question 6
Marks: 2 MCQ
Consider the following relational schema:
Doctors(doc id, doc name, address, emailID)
Department(dname, building, budget)
Appointment Details(doc id, dname, date, time)
Figure 1:
Figure 2:
Identify the correct statement for the above two query trees.
a) Two query trees are equivalent and the query tree of Figure 1 will lead to more efficient
query processing.
b) Two query trees are equivalent and the query tree of Figure 2 will lead to more efficient
query processing.
c) Two query trees are equivalent as identical operations (irrespective of their positions) are
used in both trees.
d) Two query trees are not equivalent as selection or projection operation cannot be carried
out before or after the natural join operation.
Answer: a)
Explanation: Two query trees are equivalent, and Figure 1 will lead to more efficient query
processing because performing the selection operation as early as possible reduces the size of
the relation to be joined.
Hence, option (a) is correct.
6
Question 7
Marks: 2 MSQ
Consider the following relational schema:
Doctors(doc id, doc name, address, emailID)
Department(dname, building, budget)
Appoint Details(doc id, dname, date, time)
a) Q1 is equivalent to Q2.
c) Q3 is equivalent to Q4.
Answer: a), c)
Explanation: Q1 and Q2 will give the same result because sequence of individual selections
can be combined as conjunctive selection operations over natural join of Department and
Appoint Details .
Q3 and Q4 will give the same result because σDoctors.doc id=Appoint Details.doc id is
followed by (Doctors × Appoint Details) is equivalent of (Doctors 1 Appoint Details).
Hence, options a) and c) are correct.
7
Question 8
Marks: 2 MCQ
Consider the log record of Transaction T1 with one operation instance O1 used in a recovery
system with early lock release, B+ tree based concurrency control.
Step Operation
1 ⟨T1, start⟩
2 ⟨T1, X, 500, 700⟩
3 ⟨T1, O1, operation–begin⟩
4 ⟨T1, Y, 200, 800⟩
5 ⟨T1, Z, 300, 1000⟩
6 ⟨T1, O1, operation–end,(Y, -600),(Z, -700)⟩
7 crash or abort here
Choose the correct set of log entries for the recovery of transactions.
Answer: c)
Explanation: Step i: Scan the log records backward.
Step ii: For step 6, ⟨T1, O1, operation-end, (Y, -600),(Z, -700)⟩ log is found; so, logical
undo is required for operation O1 on the variables Y and Z using the information (subtraction
of 600 for Y variable) and (subtraction of 700 for Z variable). That means we have to delete the
previous modifications on Y and Z. So, add the following logs for steps 5, 4 and 3 respectively:
⟨T1,Z, 1000, 300⟩ ⟨T1,Y, 800, 200⟩ and ⟨T1,O1, operation–abort⟩.
Step iv: For step 2, add the log ⟨T1, X, 500⟩.
Step v: For step 1, add the log ⟨T1, abort ⟩.
Hence, option (c) is correct.
8
Question 9
Marks: 2 MCQ
Consider the relation Student(SID, SName, Dept name, Mentor name) and the following re-
lational algebra expression:
ΠSID (ΠSName,SID (σDept name =‘IT’ (σMentor name=‘Newman’ (Student))))
Identify the most optimized relational algebra expression equivalent to the above relational
algebra expression.
Answer: d)
Explanation: As per the equivalence rules of relational algebra expressions, option (d) is
correct.
9
Question 10
Marks:2 MCQ
Consider the Relational Algebra expression given below:
(X1 1θ Y1 ) − (X1 1θ Z1 ) where X1 , Y1 , and Z1 are relational algebra expressions.
Identify the correct equivalent Relational Algebra expression of the above Relational Algebra
expression.
a) X1 ∩ (Y1 1θ Z1 )
b) ((X1 1θ Y1 ) − Z1 )
c) X1 1θ (Y1 − Z1 )
d) (X1 1θ Y1 ) ∩ (X1 1θ Z1 )
Answer: c)
Explanation: As per the equivalence rules of Relational Algebra expressions.
10