Complete RDBMS Questions
Complete RDBMS Questions
relation
Answers – Introduction to d) A foreign key is the primary key of a
the Relational Model relation that does not occur anywhere
else in the schema
This set of RDBMS Multiple Choice View Answer
Questions & Answers (MCQs) focuses Answer: c
on “Introduction to the Relational Explanation: A foreign key is an attribute of
Model”. a relation that is initially a primary key of
another relation. A foreign key usage
1. Choose the correct statement preserves referential integrity.
regarding superkeys 4. What action does ⋈ operator perform
a) A superkey is an attribute or a group
in relational algebra
of multiple attributes that can uniquely a) Output specified attributes from all
identify a tuple
rows of the input relation and remove
b) A superkey is a tuple or a set of duplicate tuples from the output
multiple tuples that can uniquely identify
b) Outputs pairs of rows from the two
an attribute input relations that have the same value
c) Every superkey is a candidate key on all attributes that have the same
d) A superkey is an attribute or a set of name
attributes that distinguish the relation c) Output all pairs of rows from the two
from other relations input relations (regardless of whether or
View Answer not they have the same values on
Answer: a common attributes)
Explanation: A superkey is an attribute or a d) Return rows of the input relation that
set of multiple attributes that can uniquely satisfy the predicate
identify a tuple. It is used to differentiate View Answer
between tuples.
2. What is an Instance of a Database? Answer: a
a) The logical design of the database Explanation: ⋈ Outputs specified attributes
system from all rows of the input relation. Remove
duplicate tuples from the output. The
b) The entire set of attributes of the
operation is called the join operation.
Database put together in a single
5. What does the “x” operator do in
relation
relational algebra?
c) The state of the database system at
a) Output specified attributes from all
any given point of time
rows of the input relation. Remove
d) The initial values inserted into the
duplicate tuples from the output
Database immediately after its creation
b) Output pairs of rows from the two
View Answer
input relations that have the same value
Answer: c on all attributes that have the same
Explanation: The state of the database name
system at any given point of time is called c) Output all pairs of rows from the two
as an Instance of the database. input relations (regardless of whether or
3. What is a foreign key? not they have the same values on
a) A foreign key is a primary key of a common attributes)
relation which is an attribute in another d) Returns the rows of the input relation
relation that satisfy the predicate
b) A foreign key is a superkey of a View Answer
relation which is an attribute in more
than one other relations Answer: c
c) A foreign key is an attribute of a Explanation: The “x” operator outputs all
pairs of rows from the two input relations join of book and borrow wherever the
(regardless of whether or not they have the year is lesser than 2009
same values on common attributes). This c) Selects all the tuples from the natural
operation is called as the Cartesian product join of book and student wherever the
operation and is similar to the Cartesian
year is greater than or equal to 2009
product of sets.
d) Selects all tuples from the Cartesian
6. An attribute is a __________ in a
product of book and borrow wherever
relation.
the year is greater than or equal to 2009
a) Row
View Answer
b) Column
c) Value Answer: b
d) Tuple Explanation: The condition under the select
View Answer statement represents the condition that must
be satisfied by the tuples and the symbol ⋈
Answer: b represents natural join between the two
Explanation: An attribute is a column in a relations on either side of the operator.
relation. A tuple is a row in a relation. 10. State true or false: If a relation
7. What is the method of specifying a consists of a foreign key, then it is called
primary key in a schema description? a referenced relation of the foreign key
a) By writing it in bold letters dependency.
b) By underlining it using a dashed line a) True
c) By writing it in capital letters b) False
d) By underlining it using a bold line View Answer
View Answer
Answer: b
Answer: d Explanation: If a relation has a foreign key,
Explanation: We can specify a primary key then it is called a referencing relation of the
in schema description by underlining the foreign key dependency.
respective attribute with a bold line.
8. Statement 1: A tuple is a row in a
relation RDBMS Questions and
Statement 2: Existence of multiple
foreign keys in a same relation is
Answers – SQL Data
possible definition
a) Both the statements are true
b) Statement 1 is correct but Statement This set of RDBMS Multiple Choice
2 is false Questions & Answers (MCQs) focuses
c) Statement 1 is false but Statement 2 on “SQL Data Definition”.
is correct 1. Which of the following information
d) Both the statements are false does an SQL DDL not specify?
View Answer a) The schema for each relation
Answer: a b) The integrity constraints
Explanation: A tuple is a row is a relation. c) The operations on the tuples
There can exist multiple foreign keys in the d) The security and authorization
same relation because there can exist information for each relation
multiple attributes in the relation that are View Answer
primary keys in two or more other relations.
9. Choose the option that correctly Answer: c
explains in words, the function of the Explanation: The SQL DDL does not specify
following relational algebra expression the operations that are supposed to be
made on the tuples. DDL means Data
σyear≥2009 (book ⋈ borrow)
definition language, hence it does not
a) Selects all tuples from the Cartesian include the operations made.
product of book and borrow 2. Which of the following data types
b) Selects all the tuples from the natural does the SQL standard not support?
a) char(n) database?
b) String(n) a) drop table R
c) varchar(n) b) drop relation R
d) float(n) c) delete table R
View Answer d) delete from R
View Answer
Answer: b
Explanation: The SQL standard does not Answer: a
support String(n) but it supports char, Explanation: The drop table command is
varchar and float. used to delete a relation from a database
3. Which command is used to create a whereas the delete table removes all the
new relation in SQL tuples from a relation
a) create table( , …) 7. Which of the following commands do
b) create relation( , …) we use to delete all the tuples from a
c) new table( , …) relation (R)?
d) new relation( , …) a) delete table R
View Answer b) drop table R
c) delete from R
Answer: a
d) drop from R
Explanation: We use the create table
command to create a new relation in the
View Answer
database. The syntax is Answer: c
create table( , …); Explanation: The delete from command is
4. If a1, a2, a3 are attributes in a relation used to delete all the tuples in a relation.
and S is another relation, which of the The drop table totally deletes a relation.
following is an incorrect specification of 8. Choose the correct command to
an integrity constraint? delete an attribute A from a relation R
a) primary key(a1, a2, a3) a) alter table R delete A
b) primary key(a1) b) alter table R drop A
c) foreign key(a1, a2) references S c) alter table drop A from R
d) foreign key(a1, a2) d) delete A from R
View Answer View Answer
Answer: d Answer: b
Explanation: Whenever the integrity Explanation: We can delete an attribute from
constraint foreign key is mentioned, the a relation using the alter table command
attributes that are the foreign keys should with the following syntax
always be referenced from the relation in alter table drop
which they are primary keys. 9. create table apartment(ownerID
5. What is the syntax to load data into varchar (5), ownername varchar(25),
the database? (Consider D as the floor numeric(4,0), primary key
database and a, b, c as data) (ownerID));
a) enter into D (a, b, c); Choose the correct option regarding the
b) insert into D values (a, b, c); above statement
c) insert into D (a, b, c); a) The statement is syntactically wrong
d) insert (a, b, c) values into D; b) It creates a relation with three
View Answer attributes ownerID, ownername, floor in
Answer: b
which floor cannot be null.
Explanation: To load data into a database c) It creates a relation with three
we use the insert into command. The syntax attributes ownerID, ownername, floor in
is which ownerID cannot be null.
insert into D values (a, b, c) where a, b, c d) It creates a relation with three
are the appropriate values attributes ownerID, ownername, floor in
6. Which of the following commands do which ownername must consist of at
we use to delete a relation (R) from a
least 25 characters. d) include
View Answer View Answer
Answer: c Answer: a
Explanation: It creates a relation apartment Explanation: The “all” keyword is used
with three attributes as specified. The beside the select clause to explicitly specify
attribute ownername cannot be null because that duplicates are not removed.
it is the primary key of the relation. 3. Which of the following logical
10. What does the notnull integrity connectives is not included in SQL?
constraint do? a) and
a) It ensures that at least one tuple is b) or
present in the relation c) nor
b) It ensures that at least one foreign d) not
key is present in the relation View Answer
c) It ensures that all tuples have a finite
Answer: d
value on a specified attribute
Explanation: “not” is not a logical connective
d) It ensures that all tuples have finite included in the SQL. The and, or and nor
attributes on all the relations are logical connectives that are included in
View Answer SQL.
Answer: c 4. The where clause is a predicate
Explanation: The notnull integrity constraint involving attributes of the relation in the
ensures that all the tuples have a finite value ______ clause.
on the specified attribute in the relation. It a) select
avoids the specification of null values. b) from
c) with
d) none of the mentioned
RDBMS Questions and View Answer
Answers – Basic Operations Answer: b
Explanation: The “from” clause contains the
This set of RDBMS Multiple Choice attribute names on which the “which” clause
Questions & Answers (MCQs) focuses can be used on.
on “Basic Operations”. 5. select distinct dept_name
1. Which of the following syntax of the from institute;
basic query is correct? What does the above query do?
a) select <relation> from <attribute> a) It gives all the tuples having a distinct
b) select <attribute> from <elation> dept_name
c) select <tuple> from <relation> b) It gives the dept_name attribute
d) select <tuple> from <attribute> values of all tuples without repetition
View Answer c) It gives all the dept_name attribute of
Answer: b all the tuples
Explanation: The select clause is used to d) It gives all the tuples having a null
select a specific attribute from a given value under the dept_name attribute
relation. So, the syntactically correct View Answer
statement is select <attribute> from
<relation>. Answer: b
Explanation: The distinct keyword is used to
2. Which of the following keywords is
explicitly force the elimination of duplicate
used beside the select clause to tuples. Thus, the above query excludes
explicitly specify that duplicates are not duplicates.
removed? 6. What does the following query do?
a) all select name, ID, branch
b) not unique from student, department
c) notnull where student.branch =
department.branch; 9. State true or false: Multiple conditions
a) It gives all values of name, ID, branch in the where clause are separated by a
from both the relations only if all those “,”
attributes are present in both a) True
b) It gives all values of name, ID, branch b) False
from their respective relations View Answer
c) It gives the values of name, ID,
Answer: b
branch from their respective relations Explanation: Multiple conditions in the where
where the values in the branch attribute clause are separated by the “and” keyword.
are same 10. What does the natural join operation
d) It gives the values of name, ID, do?
branch from their respective relations a) It considers only those pairs of tuples
where all the values are matching with that have the same value on those
each other attributes that appear in the schemas of
View Answer both relations
Answer: c b) It considers only those pairs of tuples
Explanation: student.branch = that have the same value on at least one
department.branch verifies whether both the of the attributes that appear in the
values of the attributes are same in both the schemas of both the relations
relations and returns the value. c) It considers only those pairs of tuples
7. The ________ clause is used to list that do not have the same value on
the attributes desired in the result of a those attributes that appear in the
query schemas of both relations
a) select d) None of the mentioned
b) from View Answer
c) where
d) create Answer: a
Explanation: The natural join operation
View Answer
considers only those pairs of tuples that
Answer: a have the same value on those attributes that
Explanation: The select clause is used to list appear in the schemas of both the relations.
the attributes desired in the result of a The natural join operation operates on 2
query. relations and gives a relation as the result.
8. If we specify multiple relations in the 11. Observe the following query and
from clause and do not specify any choose the correct option.
conditions in the where clause, what will select name, ID
the result be? from student natural join department
a) The natural join of both the relations natural join section
b) The left outer join of both the relations a) The query is syntactically wrong
c) A syntactical error because there is no where clause
d) The Cartesian product of both the b) The query is syntactically wrong
relations because there are more than one
View Answer attributes in the select clause
c) The query is syntactically wrong
Answer: d
because more than one relations are
Explanation: If we specify multiple relations
in the from clause and do not specify any
included in the natural join operation
conditions in the where clause, the default d) The query is correct
definition given by the from clause is the View Answer
Cartesian product of the relations listed in Answer: d
the clause. So it returns all the possible Explanation: The query is syntactically
combinations of the tuples of the two correct because, where clause is not
relations. necessary in a query, more than one
attributes can be specified in the select
clause and more than one relations may be Answer: b
operated on, using the natural join operator. Explanation: The union operation combines
advertisement the results of two different queries which
have the same set of attributes in the select
12. Which keyword is used to rename a clause. It automatically eliminates
relation in a query? duplicates.
a) rename 2. What is the function of the intersect
b) as operation?
c) is a) It returns the intersection of the
d) to results of the results of any two different
View Answer queries
b) It returns the intersection of the
Answer: b
Explanation: The “as” keyword is used to results of two different queries which
rename a relation in a query. This is used have the same set of attributes in the
for convenience as long relation names can select clause
reduce readability. c) It returns the intersection of the
13. While operating with strings, what results of two different queries which
does “_ _ _%” match with? have the same condition in the where
a) A string of three letters clause
b) A string of at least three letters d) None of the mentioned
c) A string of three words View Answer
d) A string of at least three words Answer: b
View Answer Explanation: The intersect operation returns
Answer: a the intersection of the results of the results
Explanation: The string in the question of two different queries which have the
matches with a string having at least three same set of attributes in the select clause. It
letters. The first three blank spaces indicate automatically eliminates duplicates.
three letters whereas the percentage 3. What is the function of the except
indicates indefinite spaces after that. operation?
a) It excludes all the results present in
both the queries
RDBMS Questions and b) It includes the results of the second
Answers – Set Operations query but excludes the results of the first
query
This set of RDBMS Multiple Choice c) It includes the results of the first query
Questions & Answers (MCQs) focuses but excludes the results of the second
on “Set Operations”. query
d) It includes all the results of both
1. What is the function of the union queries but removes duplicates
operation? View Answer
a) It combines the results of any two
different queries Answer: c
b) It combines the results of two different Explanation: The except operation includes
the results of the first query but excludes the
queries which have the same set of results of the second query. It automatically
attributes in the select clause eliminates duplicates but if we want to retain
c) It combines the results of two different duplicates we must use except all in place of
queries which have the same condition except.
in the where clause 4. When does the predicate is null
d) It gives the Cartesian product of the succeed?
results of any 2 queries a) If the value on which it is applied is
View Answer finite
b) If the value on which it is applied is
invalid
c) If the value on which it is applied is a) All the values of the studentid for
blank which section is c and roll < 10
d) If the value on which it is applied is b) All the values of the studentid for
more than the allowed limit which section is c and roll > 10
View Answer c) All the values of the studentid for
which section not c and roll < 10
Answer: c
Explanation: The is null predicate succeeds
d) All the values of the studentid for
when the value on which it is applied is which section not c and roll > 10
blank/null. View Answer
5. Using the _______ clause retains Answer: b
only one copy of identical tuples Explanation: The except operation excludes
a) distinct all the tuples that are present in the result of
b) is not null the second query from the result of the first
c) no repeat query. It also excludes all duplicates from
d) from the relation.
View Answer advertisement
Answer: a Answer: b
Explanation: A schedule is conflict Explanation: If I = read(Q) and J = write(Q)
serializable if it is conflict equivalent to a then the order of I and J matters because
serial schedule. The concept of conflict both I and J are different operations on the
equivalence leads to the concept. query. The order of execution determines
the state of the database that is being read
4. The set of ________ in a precedence
or written.
graph consists of all the transactions advertisement
participating in the schedule
a) Vertices 8. Which of the following is the most
b) Edges expensive method?
c) Directions a) Timestamping
d) None of the mentioned b) Plain locking
View Answer c) Predicate locking
Answer: a d) Snapshot isolation
Explanation: The set of vertices in a View Answer
precedence graph consists of all the Answer: c
transactions participating in the schedule. Explanation: Predicate locking is the most
Precedence graph is a simple and efficient expensive method and is generally not used
way of determining conflict serializability of in most databases.
the schedule.
5. A ___________of the transactions
can be obtained by finding a linear order RDBMS Questions and
consistent with the partial order of the
precedence graph. Answers – Transaction
a) Serializability order Isolation
b) Direction graph
c) Precedence graph This set of RDBMS Multiple Choice
d) Scheduling scheme Questions & Answers (MCQs) focuses
View Answer on “Transaction Isolation”.
1. A transaction that performs only one Tj such that Tj reads a data item previously
operation is called as a _________ written by Ti , the commit operation of Ti
a) Partial schedule appears before the commit operation of Tj.
b) Complete schedule 5. State true or false: Transactions can
c) Dependent schedule only run serially
d) Independent schedule a) True
View Answer b) False
View Answer
Answer: a
Explanation: A transaction that performs Answer: b
only one operation is called as a partial Explanation: Transactions are safer run
schedule because we don’t include commit serially but can also be run concurrently.
or rollback operations on them. 6. Which of the following are the
2. The phenomenon in which one failure advantages of transaction concurrency?
leads to a series of transaction rollbacks a) Increased throughput
is called as ________ b) Increased utilization
a) Cascading rollback c) Reduces average response time
b) Cascadeless rollback d) All of the mentioned
c) Cascade cause View Answer
d) None of the mentioned Answer: d
View Answer Explanation: Concurrency in transactions
Answer: a allow increased throughput, utilization. They
Explanation: The phenomenon in which one also reduce average response time.
failure leads to a series of transaction 7. The average time for a transaction to
rollbacks is called as cascading rollback. be completed after it has been
B=It is named so because one failure submitted is called as __________
causes the rollback of several other a) Minimum response time
transactions serially. b) Average response time
3. State true or false: Every cascadeless c) Average reaction time
schedule is also recoverable d) Minimum reaction time
a) True View Answer
b) False
View Answer Answer: b
Explanation: The average time for a
Answer: a transaction to be completed after it has been
Explanation: Every cascadeless schedule is submitted is called as Average response
also recoverable because in a cascadeless time. This gets decreased when
schedule, the commit operations occur in concurrency is used in transactions.
the same sequence as that of write and read advertisement
operations of two transactions respectively.
4. A ___________ is one where, for 8. If a schedule is equivalent to a serial
each pair of transactions Ti and Tj such schedule, it is called as a _________
that Tj reads a data item previously a) Serializable schedule
written by Ti , the commit operation of Ti b) Equivalent schedule
appears before the commit operation of c) Committed schedule
Tj d) None of the mentioned
a) Partial schedule View Answer
b) Dependent schedule Answer: a
c) Recoverable schedule Explanation: If a schedule is equivalent to a
d) None of the mentioned serial schedule, it is called as a Serializable
View Answer schedule.
9. Which of the following is not a type of
Answer: c
Explanation: A Recoverable schedule is one a schedule?
where, for each pair of transactions Ti and a) Partial schedule
b) Dependent schedule Answer: c
c) Recoverable schedule Explanation: Repeatable read allows only
d) None of the mentioned committed data to be read and further
View Answer requires that no other transaction is allowed
to update it between two reads of a data
Answer: d item by a transaction. However, the
Explanation: All of the mentioned schedules transaction may not be serializable with
i.e. partial schedule, dependent schedule, respect to other transactions.
recoverable schedule are different types of 4. ________ allows only committed data
schedules. to be read, but does not require
repeatable reads
a) Read uncommitted
RDBMS Questions and b) Serializable
Answers – Transaction c) Repeatable read
d) Read committed
Isolation Levels View Answer
This set of RDBMS Question Bank Answer: d
focuses on “Transaction Isolation Explanation: Read committed allows only
Levels”. committed data to be read, but does not
require repeatable reads. For instance,
1. Which of the following is a transaction between two reads of a data item by the
isolation level as specified by SQL transaction, another transaction may have
standard? updated the data item and committed.
a) Serializable 5. ___________ allows uncommitted
b) Repeatable read data to be read
c) Read committed a) Read uncommitted
d) All of the mentioned b) Serializable
View Answer c) Repeatable read
d) Read committed
Answer: a
Explanation: Serializable, repeatable read,
View Answer
read committed and read uncommitted are Answer: a
the four levels of transactions. Explanation: Real uncommitted allows
2. State true or false: Serializable level uncommitted data to be read. It is the lowest
may allow both serializable and non- isolation level allowed by SQL.
serializable executions 6. State true or false: All the isolation
a) True levels disallow dirty writes
b) False a) True
View Answer b) False
View Answer
Answer: a
Explanation: Serializable level generally Answer: a
allows only serializable executions but in Explanation: All the isolation levels above
some special cases, it may also allow non- additionally disallow dirty writes, that is, they
serializable execution. Disallow writes to a data item that has
3. ________ allows only committed data already been written by another transaction
to be read and further requires that no that has not yet committed or aborted.
other transaction is allowed to update it 7. When is a timestamp allotted
between two reads of a data item by a a) When execution begins
transaction. b) When execution is taking place
a) Read uncommitted c) When execution is completed
b) Serializable d) None of the mentioned
c) Repeatable read View Answer
d) Read committed
View Answer
Answer: a a) Shared mode
Explanation: Timestamp is allotted when b) Exclusive mode
execution of a transaction begins. c) Read only mode
advertisement d) Write only mode
8. In ___________ isolation each View Answer
transaction is given its own version of Answer: b
the database Explanation: If a transaction has obtained an
a) Timestamp exclusive mode lock, then it can both read
b) Snapshot and write on the item on which it in
c) Lock based operating.
d) All of the mentioned 3. A transaction can proceed only after
View Answer the concurrency control manager
________ the lock to the transaction
Answer: b a) Grants
Explanation: In snapshot isolation, each b) Requests
transaction is given its own version or
c) Allocates
snapshot of the database on which it can
operate. d) None of the mentioned
9. What is the disadvantage of locking? View Answer
a) Does not control concurrency Answer: a
b) Is not atomic Explanation: A transaction can proceed only
c) Is not durable after the concurrency control manager
d) Has a poor degree of concurrency grants the lock to the transaction.
View Answer 4. If a transaction can be granted a lock
on an item immediately in spite of the
Answer: Locking has a poor degree of presence of another mode, then the two
concurrency. It in fact has no concurrency at
modes are said to be ________
all.
a) Concurrent
b) Equivalent
RDBMS Questions and c) Compatible
d) Executable
Answers – Lock Based View Answer
Protocols Answer: c
Explanation: If a transaction can be granted
This set of RDBMS Multiple Choice a lock on an item immediately in spite of the
Questions & Answers (MCQs) focuses presence of another mode, then the two
on “Lock Based Protocols”. modes are said to be compatible.
5. A transaction is made to wait until all
1. If a transaction has obtained a
________ locks held on the item are
__________ lock, it can read but cannot
released
write on the item
a) Compatible
a) Shared mode
b) Incompatible
b) Exclusive mode
c) Concurrent
c) Read only mode
d) Equivalent
d) Write only mode
View Answer
View Answer
Answer: a
Answer: a
Explanation: A transaction is made to wait
Explanation: If a transaction Ti has obtained
until all compatible locks held on the item
a shared-mode lock (denoted by S) on item
are released. This ensures that no other
Q, then Ti can read, but cannot write, Q.
transaction is concurrently accessing the
2. If a transaction has obtained a same item.
________ lock, it can both read and 6. State true or false: It is not necessarily
write on the item desirable for a transaction to unlock a
data item immediately after its final c) More than one of the mentioned
access d) None of the mentioned
a) True View Answer
b) False
Answer: c
View Answer Explanation: The two phased locking
Answer: a protocol consists of the growing phase and
Explanation: It is not necessarily desirable the shrinking phase.
for a transaction to unlock a data item advertisement
immediately after its final access because
serializability may be violated due to this. 11. If a transaction may obtain locks but
7. The situation where no transaction may not release any locks then it is in
can proceed with normal execution is _______ phase
known as ________ a) Growing phase
a) Road block b) Shrinking phase
b) Deadlock c) Deadlock phase
c) Execution halt d) Starved phase
d) Abortion View Answer
View Answer Answer: a
Answer: b Explanation: If a transaction may obtain
Explanation: The situation where no locks but may not release any locks then it
transaction can proceed with normal is in growing phase. Growing phase is a
execution is known as a deadlock. phase in two phased locking protocol.
8. The protocol that indicates when a 12. If a transaction may release locks
transaction may lock and unlock each of but may not obtain any locks, it is said to
the data items is called as __________ be in ______ phase
a) Locking protocol a) Growing phase
b) Unlocking protocol b) Shrinking phase
c) Granting protocol c) Deadlock phase
d) Conflict protocol d) Starved phase
View Answer View Answer
Answer: a Answer: b
Explanation: The protocol that indicates Explanation: If a transaction may release
when a transaction may lock and unlock locks but may not obtain any locks, it is said
each of the data items is called as locking to be in shrinking phase. Shrinking phase is
protocol. Locking protocols restrict the a phase in two phased locking protocol.
number of schedules.
9. If a transaction Ti may never make
progress, then the transaction is said to
RDBMS Questions and
be ____________ Answers – Deadlock
a) Deadlocked Handling
b) Starved
c) Committed This set of RDBMS Multiple Choice
d) Rolled back Questions & Answers (MCQs) focuses
View Answer on “Deadlock Handling”.
Answer: b 1. A system is in a _______ state if there
Explanation: If a transaction Ti may never
exists a set of transactions in which
make progress, then the transaction is said
to be starved. every transaction is waiting for another
10. The two phase locking protocol transaction in the set.
consists which of the following phases? a) Deadlock
a) Growing phase b) Starved
b) Shrinking phase c) Isolated
d) None of the mentioned transactions do not starve and it is also easy
View Answer to implement and is hence widely used if
transactions are short and long waits are
Answer: a likely to be due to deadlocks.
Explanation: A system is in a deadlock state 6. The _________ graph describes
if there exists a set of transactions in which deadlocks precisely
every transaction is waiting for another
a) Wound wait graph
transaction in the set.
b) Wait die graph
2. Which of the following is not a method
c) Wait for graph
in deadlock handling
d) None of the mentioned
a) Deadlock prevention
View Answer
b) Deadlock detection
c) Deadlock recovery Answer: c
d) Deadlock distribution Explanation: The wait for graph describes
View Answer deadlocks precisely. Existence of a cycle in
this graph implies that a deadlock will occur.
Answer: d 7. How do we generally recover from a
Explanation: Deadlock distribution is not a deadlock?
method in deadlock handling whereas,
a) By aborting all the transactions
deadlock prevention is followed by deadlock
detection and deadlock recovery.
b) By rolling back all the transactions
3. Deadlocks can be prevented using c) By rolling back only a selected
a) Preemption and transaction rollbacks number of transactions
b) Wait and die scheme d) None of the mentioned
c) Wound-wait scheme View Answer
d) All of the mentioned Answer: c
View Answer Explanation: We generally recover from
deadlocks by rolling back only a selected
Answer: d number of transactions
Explanation: Preemption and transaction advertisement
rollbacks, wait and die scheme, wound wait
scheme are all different methods of 8. State true or false: Partial rollback is
deadlock prevention. not possible.
4. State true or false: Wait die scheme is a) True
a non-preemptive technique b) False
a) True View Answer
b) False
View Answer Answer: b
Explanation: Partial rollback is possible but it
Answer: a requires the system too maintain an
Explanation: The wait-die scheme is a non- additional amount of information on the
preemptive technique. When transaction Ti states of the transactions.
requests a data item currently held by Tj , Ti 9. Which of the following steps must be
is allowed to wait only if it has a timestamp taken while choosing a victim?
smaller than that of Tj (that is, Ti is older a) Avoiding starvation
than Tj ). Otherwise, Ti is rolled back (dies).
b) Number of transactions involved in
5. Lock timeouts have which of the
rollback
following advantages?
c) Data items used by the transaction
a) Unnecessary rollbacks do not occur
d) All of the mentioned
b) Transactions do not starve
View Answer
c) It is easy to implement
d) All of the mentioned Answer: d
View Answer Explanation: While choosing a victim we
much choose the one with a minimum cost.
Answer: d That is the one which avoids starvation, the
Explanation: In lock timeout method, one with the least number of transaction
unnecessary rollbacks do not occur,
involved in the rollback and the one with the largest timestamp of any transaction that
least amount of data items used. can execute write(Q) successfully.
4. R-timestamp(Q) denotes?
a) The largest timestamp of any
RDBMS Questions and transaction that can execute write(Q)
Answers – Timestamp successfully
b) The largest timestamp of any
based Protocols transaction that can execute read(Q)
successfully
This set of Basic RDBMS Questions and c) The smallest timestamp of any
Answers focuses on “Timestamp Based transaction that can execute write(Q)
Protocols”. successfully
1. Which of the following cannot be used d) The smallest timestamp of any
to implement a timestamp transaction that can execute read(Q)
a) System clock successfully
b) Logical counter View Answer
c) External time counter Answer: b
d) None of the mentioned Explanation: R-timestamp(Q) denoted the
View Answer largest timestamp of any transaction that
Answer: c can execute read(Q) successfully.
Explanation: An external time counter 5. A ________ ensures that any
cannot be used to implement a timestamp. conflicting read and write operations are
System clock and a logical counter can be executed in timestamp order
used. a) Organizational protocol
2. A logical counter is _________ after a b) Timestamp ordering protocol
new timestamp has been assigned c) Timestamp execution protocol
a) Incremented d) 802-11 protocol
b) Decremented View Answer
c) Doubled
Answer: b
d) Remains the same Explanation: A timestamp ordering protocol
View Answer ensures that any conflicting read and write
Answer: a operations are executed in timestamp order.
Explanation: A logical counter is 6. The default timestamp ordering
incremented after a new timestamp has protocol generates schedules that are
been assigned everytime. a) Recoverable
3. W-timestamp(Q) denotes? b) Non-recoverable
a) The largest timestamp of any c) Starving
transaction that can execute write(Q) d) None of the mentioned
successfully View Answer
b) The largest timestamp of any
Answer: b
transaction that can execute read(Q) Explanation: The timestamp ordering
successfully protocol generates schedules that are non-
c) The smallest timestamp of any recoverable. But it can be extended to make
transaction that can execute write(Q) the schedules recoverable.
successfully 7. State true or false: The Thomas write
d) The smallest timestamp of any rule has a greater potential concurrency
transaction that can execute read(Q) than the timestamp ordering protocol
successfully a) True
View Answer b) False
Answer: a
View Answer
Explanation: W-timestamp(Q) denotes The
Answer: a write(Q) operation and the transaction Ti
Explanation: The Thomas write rule has a rolls back.
greater potential concurrency than the
timestamp ordering protocol. This is
because it is a modified version of the RDBMS Questions and
timestamp ordering protocol in which
obsolete write operations can be ignored Answers – Validation Based
under certain circumstances. Protocols
8. Which of the following timestamp
based protocols generates serializable This set of RDBMS Multiple Choice
schedules? Questions & Answers (MCQs) focuses
a) Thomas write rule on “Validation Based Protocols”.
b) Timestamp ordering protocol
c) Validation protocol 1. The _________ requires each
d) None of the mentioned transaction executes in two or three
View Answer different phases in its lifetime
a) Validation protocol
Answer: a b) Timestamp protocol
Explanation: Thomas write rule protocol c) Deadlock protocol
generates serializable schedules that no d) View protocol
other protocol can generate.
View Answer
9. In timestamp ordering protocol,
suppose that the transaction Ti issues Answer: a
read(Q) and TS(Ti)<W-timestamp(Q), Explanation: The validation protocol requires
then each transaction to execute in two or three
a) Read operation is executed different phases in its lifetime depending on
whether it is a read only or an update
b) Read operation is rejected
transaction.
c) Write operation is executed
2. During __________ phase, the
d) Write operation is rejected
system reads data and stores them in
View Answer
variables local to the transaction.
Answer: b a) Read phase
Explanation: Suppose that transaction Ti b) Validation phase
issues read(Q). If TS(Ti ) < W-timestamp(Q), c) Write phase
then Ti needs to read a value of Q that was d) None of the mentioned
already overwritten. Hence, the read View Answer
operation is rejected, and Ti is rolled back.
10. In timestamp ordering protocol, Answer: a
suppose that the transaction Ti issues Explanation: During the read phase, the
write(Q) and TS(Ti)<W-timestamp(Q), system reads data and stores them in
then variables local to the transaction. It performs
all write operations on temporary local
a) Read operation is executed
variables without updates on the actual
b) Read operation is rejected database.
c) Write operation is executed 3. During the _________ phase the
d) Write operation is rejected validation test is applied to the
View Answer transaction
Answer: d a) Read phase
Explanation: In timestamp ordering protocol, b) Validation phase
suppose that the transaction Ti issues c) Write phase
write(Q) and TS(Ti)<W-timestamp(Q), then d) None of the mentioned
the value of Q that Ti is producing was View Answer
needed previously, and the system
assumed that the value would never be Answer: b
produced. Hence the system rejects the Explanation: During the validation phase,
the validation test is applied to the
transaction. This determines whether the timestamps for each transaction start(i),
transaction is allowed to proceed or not validation(i), finish(i). The validation phase is
without causing a violation of serializability. used to record the time at which a
4. During the _______ phase, the local transaction has finished its read phase and
variables that hold the write operations has started its validation phase.
are copied to the database 8. Which of the following timestamps is
a) Read phase used to record the time when a
b) Validation phase database has completed its write
c) Write phase operation?
d) None of the mentioned a) Start(i)
View Answer b) Validation(i)
c) Finish(i)
Answer: c d) Write(i)
Explanation: During the write phase, the
View Answer
local variables that hold the write operations
are copied to the database. Read only Answer: c
operations omit this phase. Explanation: There are three different
5. Read only operations omit the timestamps for each transaction start(i),
_______ phase validation(i), finish(i). Finish(i) is used to
a) Read phase record the time when a transaction has
b) Validation phase finished its write phase.
c) Write phase 9. State true or false: Locking and
d) None of the mentioned timestamp ordering force a wait or
View Answer rollback whenever a conflict is detected.
a) True
Answer: c b) False
Explanation: Read only operations do not View Answer
allow write operation to be performed on
them. So, they omit the write phase but Answer: a
execute the read and validation phases. Explanation: Locking and timestamp
6. Which of the following timestamp is ordering force a wait or rollback whenever a
used to record the time at which the conflict is detected. This property is called
transaction started execution? pessimism of locking and timestamp
a) Start(i) protocols.
b) Validation(i) 10. State true or false: We determine the
c) Finish(i) serializability order of validation protocol
d) Write(i) by the validation ordering technique
View Answer a) True
b) False
Answer: a View Answer
Explanation: There are three different
timestamps for each transaction start(i), Answer: b
validation(i), finish(i). Start(i) is used to Explanation: We determine the serializability
record the time at which the transaction order of the validation protocol by the
execution started. timestamp ordering technique. There is no
7. Which of the following timestamps is technique called as the validation ordering
used to record the time when a technique to determine the serializability
order of the validation protocol.
transaction has finished its read phase?
a) Start(i)
b) Validation(i) RDBMS Questions and
c) Finish(i)
d) Write(i) Answers – Multiversion
View Answer Schemes, Snapshot
Answer: b Isolation
Explanation: There are three different
This set of RDBMS Questions and 5. Under ________ the system uses
Answers for Entrance exams focuses on locking mechanism that applies only to
“Multiversion Schemes, Snapshot updates
Isolation”. a) First updater wins
b) First committer wins
1. In _______ schemes, each write
c) First writer wins
operation creates a new version of Q d) None of the mentioned
a) Multiversion
View Answer
b) Snapshot isolation
c) Lock based Answer: a
d) Timestamp Explanation: Under first updater wins, the
View Answer system uses a locking mechanism that
applies only to updates. Read operations do
Answer: a not get affected by this mechanism.
Explanation: In multiversion schemes, each 6. The situation in which each pair of
write operation creates a new version of Q. transactions has read a data written by
When a transaction issues a read operation, the other, but there is no data written by
the concurrency control manager selects
the transactions is called as _______
one of the versions of Q to be read.
a) Deadlock
2. If the first update is overwritten by a
b) Read skew
second, it is called as a _______ update
c) Deadlock skew
a) Useful
d) Write skew
b) Overlapping
View Answer
c) Lost
d) Concurrent Answer: d
View Answer Explanation: The situation in which each
pair of transactions has read a data written
Answer: c by the other, but there is no data written by
Explanation: If the first update is overwritten the transactions is called as write skew.
by a second, it is called as a lost update. 7. Oracle uses __________ for the
This generally occurs whenever two
serializable isolation level
transactions are allowed to write on the
database.
a) Multiversion scheme
3. State true or false: Snapshot isolation b) Timestamp protocol
prevents lost updates c) Lock based protocol
a) True d) Snapshot isolation
b) False View Answer
View Answer Answer: d
Explanation: Oracle uses snapshot isolation
Answer: a
for the serializable isolation level.
Explanation: Snapshot isolation prevents
PostgreSQL also uses only snapshot
lost updates because it does not allow two
isolation for the serializable isolation level.
transactions to simultaneously write on the
same database.
8. State true or false: Snapshot isolation
4. Which of the following is a variant of has low overhead
snapshot isolation a) True
a) First committer wins b) False
b) First updater wins View Answer
c) More than one of the mentioned Answer: a
d) None of the mentioned Explanation: Snapshot isolation is attractive
View Answer in practice because it has a relatively very
low overhead.
Answer: c 9. In ________ no two aborts occur
Explanation: First committer wins and first
unless two concurrent transactions
updater wins are two different variations of
snapshot isolation.
update the same data item.
a) Multiversion scheme
b) Timestamp protocol b) Phantom problem
c) Lock based protocol c) Index locking
d) Snapshot isolation d) Index problem
View Answer View Answer
Answer: d Answer: c
Explanation: In snapshot isolation no two Explanation: Index locking avoids locking
aborts occur unless two concurrent the entire index. Any transaction that inserts
transactions update the same data item. a tuple into a relation must insert information
This makes snapshot isolation attractive but into every index maintained on the relation.
it does not ensure serializability. 3. Which of the following is included in
10. Which of the following transactions the operational mechanism of the index
can multiversion two phase locking locking protocol?
protocol not differentiate. a) Every transaction must have at least
a) Read only transactions one index
b) Update transactions b) A transaction that performs a lookup
c) All of the mentioned must acquire a shared lock on all the
d) Double operator transactions index leaf nodes that it accesses
View Answer c) The rule of the two phase locking
Answer: d
mechanism must be observed
Explanation: The multiversion two phase d) All of the mentioned
locking protocol cannot differentiate double View Answer
operator transactions but it can differentiate Answer: d
between read only transactions and update Explanation: The operational mechanism of
transactions. the index locking protocol includes, every
transaction must have at least one index. A
transaction that performs lookup must
RDBMS Questions and acquire a shared lock on all the index leaf
Answers – Insert, Delete nodes that it accesses. The rule of the two
phase locking mechanism must be followed.
Operations and Predicate 4. _________ is a form of two degree
Reads consistency designed for programs that
iterate over tuples of a relation by using
This set of RDBMS Multiple Choice cursors.
Questions & Answers (MCQs) focuses a) Cursor stability
on “Insert, Delete Operations and b) Serializability
Predicate Reads”. c) Non-serializability
d) Predicate locking
1. ________ deletes a data item from a View Answer
database
a) Delete(Q) Answer: a
b) Insert(Q) Explanation: Cursor stability is a form of two
c) Drop(Q) degree consistency designed for programs
that iterate over tuples of a relation by using
d) None of the mentioned
cursors. It ensures that the tuple that is
View Answer currently being processed is locked in
Answer: a shared mode and any modified tuples are
Explanation: Delete(Q) deletes a data item locked in exclusive mode until the
from a database. Insert(Q) inserts a new transaction commits.
data item Q into the database and assign Q 5. Transactions that involve user
an initial value. interactions are called __________
2. Which of the following does not lock a) Validations
the entire index b) Conversations
a) Phantom locking c) Interfaces
d) None of the mentioned 9. State true or false: Exclusive locks are
View Answer held until transaction commit in degree
two consistency
Answer: b
Explanation: Transactions that involve user
a) True
interactions are called as conversation. b) False
These are named differently to differentiate View Answer
them from regular transactions. Validation Answer: a
using version numbers is very useful for Explanation: Exclusive locks are held until
such transactions. transaction commit in degree two
6. State true or false: Key value locking consistency, no transaction can read an
provides increased concurrency uncommitted value.
a) True
b) False
View Answer RDBMS Questions and
Answer: a Answers – Failure
Explanation: Key value locking provides
increased concurrency. Using key value
Classification and Storage
improperly however might cause phantom
phenomenon to occur.
This set of RDBMS Problems focuses
7. To prevent the phantom on “Failure Classification and Storage”.
phenomenon, _______ is used 1. Which of the following can cause a
a) Key value locking transaction failure
b) Next key locking a) Logical error
c) Previous key locking b) System error
d) None of the mentioned c) More than one of the mentioned
View Answer d) None of the mentioned
Answer: b View Answer
Explanation: The failure of a system to Answer: c
prevent a non serialized tuple when two Explanation: Logical errors and system
transactions conflict with each other is called errors are the two types of errors that can
as phantom phenomenon. To prevent the generally cause transaction failures.
phantom phenomenon, the next key locking 2. If the transaction can no longer
is used.
continue with its normal execution
advertisement
because of some internal condition, it is
8. Which of the following does cursor called as a _________
stability ensure a) Logical error
a) The tuple that is currently being b) System error
processed by the iteration is locked in c) System crash
shared mode d) None of the mentioned
b) The tuple that is currently being View Answer
processed is not locked in shared mode Answer: a
c) Any modified tuples are not locked in Explanation: If the transaction can no longer
exclusive mode continue with its normal execution because
d) None of the mentioned of some internal condition, it is called as a
View Answer logical error such as bad input, data not
found, overflow or resource limit exceeded.
Answer: a 3. If a system has entered and
Explanation: Cursor stability ensures that
undesirable state due to which it is
the tuple that is currently being processed
by the iteration is locked in shared mode unable to continue with normal
and any modified tuples are locked in execution, it is called as _________
exclusive mode until the transaction a) Logical error
commits. b) System error
c) System crash storage is the least secure whereas stable
d) None of the mentioned storage is the most secure among them.
View Answer 7. If a failure has occurred in the midst of
a transfer, it is called as _________
Answer: b a) Successful completion
Explanation: If a system has entered and
b) Partial failure
undesirable state due to which it is unable to
continue with normal execution, it is called
c) Total failure
as a system error. The transaction however d) None of the mentioned
can be re-executed at a later time. View Answer
4. If there is a hardware malfunction or a Answer: b
bug in the database that causes the loss Explanation: If a failure has occurred in the
of content of volatile storage, it is called midst of a transfer, it is called as partial
as ________ failure. After a partial failure, the destination
a) Logical error has incorrect information.
b) System error 8. State true or false: The destination
c) System crash block has incorrect information in case
d) None of the mentioned of a total failure
View Answer a) True
b) False
Answer: c
View Answer
Explanation: If there is a hardware
malfunction or a bug in the database that Answer: b
causes the loss of content of volatile Explanation: In case of total failure, the
storage, it is called as a system crash. The failure occurs sufficiently early during the
data in the non-volatile storage remains transfer that the destination block remains
intact and it is not corrupted. intact. Thus there is no corruption of data at
5. The assumption that the hardware the destination.
errors bring the system to a halt is called 9. The partitions of the database into
as ________ fixed length storage units are called as
a) Halter assumption __________
b) Phantom assumption a) Blocks
c) Fail-stop assumption b) Tuples
d) Disk failure c) Relations
View Answer d) None of the mentioned
View Answer
Answer: c
Explanation: The assumption that the Answer: a
hardware errors bring the system to a halt is Explanation: The database is partitioned into
called as fail-stop assumption. Well- fixed length storage units called as blocks.
designed systems have numerous internal Blocks are the units of data transfer and
checks that bring a system to a halt may contain several data items.
whenever there is an error. Hence, the fail 10. The blocks residing on the disk are
stop assumption is a reasonable one. referred to as ___________
6. Which of the following is not a a) Physical blocks
classification of storage b) Buffer blocks
a) Volatile storage c) Disk blocks
b) Nonvolatile storage d) Disk buffer
c) Stable storage View Answer
d) None of the mentioned
View Answer Answer: a
Explanation: The blocks residing on the disk
Answer: d are referred to as physical blocks. The
Explanation: Volatile storage, non-volatile blocks residing temporarily in the main
storage and stable storage are three memory are referred to as buffer blocks.
different classifications of storage. Volatile advertisement
11. The area of memory where blocks c) Old value
temporarily reside is called as ________ d) All of the mentioned
a) Block buffer View Answer
b) Disk buffer
Answer: d
c) Physical buffer Explanation: An update log record describes
d) None of the mentioned a single database write. It has four fields in
View Answer it. The update log record has a transaction
Answer: b identifier, data-item identifier, old value, new
Explanation: The area of memory where value.
blocks temporarily reside is called as the 4. The unique identifier of the
disk buffer. The disk buffer is used to store transaction that performed the write
the buffer blocks which hold temporary data. operation is called as _______
a) Transaction identifier
b) Data-item identifier
RDBMS Questions and c) Old value
Answers – Recovery and d) New value
View Answer
Atomicity
Answer: a
This set of RDBMS Multiple Choice Explanation: The unique identifier of the
Questions & Answers (MCQs) focuses transaction that performed the write
operation is called as transaction identifier.
on “Recovery and Atomicity”.
This is a field in the update log record.
1. The most widely used structure for 5. The value of the data item prior to the
recording database modification is write is called as _________
called as _______ a) Transaction identifier
a) Log b) Data-item identifier
b) List c) Old value
c) Queue d) New value
d) Stack View Answer
View Answer Answer: c
Answer: a Explanation: The value of the data item prior
Explanation: The most widely used structure to the write is called as old value. This is
for recording database modification is called stored in the update log record.
as a log. The log is a sequence of log 6. If a transaction does not modify the
records recording all the update activities in database until it has committed it is said
the database. to use a _______ modification technique
2. An update log record describes a a) Deferred
________ database write b) Immediate
a) Single c) More than one of the mentioned
b) Double d) None of the mentioned
c) Triple View Answer
d) Quadruple
Answer: a
View Answer
Explanation: If a transaction does not modify
Answer: a the database until it has committed it is said
Explanation: An update log record describes to use a deferred modification technique.
a single database write. It has four fields in it Deferred modification has the overhead that
which are, transaction identifier, data-item transactions need to make local copies of all
identifier, old value, new value. updated data items.
3. Which of the following fields does the 7. We say that a transaction has been
update log record have? ________ when its commit log record
a) Transaction identifier has been output to stable storage.
b) Data-item identifier a) Locked
b) Completed RDBMS Questions and
c) Committed
d) Released Answers – SQL Data
View Answer Definition
Answer: c
Explanation: We say that a transaction has This set of RDBMS Multiple Choice
been committed when its commit log record Questions & Answers (MCQs) focuses
has been output to stable storage. At that on “SQL Data Definition Problems (Bank
point, all the earlier records have already Database Schema)”.
been output to stable storage.
8. State true or false: Using checkpoints Q1) Create a Bank Database schema
reduces overhead with the following relations and select an
a) True appropriate primary key.
b) False account(account_number,
View Answer branch_name, balance)
branch (branch_name, branch_city,
Answer: a assets)
Explanation: Using checkpoints reduces customer (customer_name
overhead because the search process is customer_street, customer_city)
time consuming and searching for
loan (loan_number, branch_name,
transactions does not take place if we use
checkpoints. amount)
9. A __________ checkpoint is a depositor((customer_name,
checkpoint where transactions are account_number)
allowed to perform updates even while borrower(customer_name,
buffer blocks are being written out. loan_number)
a) Temporary View Answer
b) Fuzzy Answer: create table account
c) Permanent (account_number varchar(15) not null
d) Recovery unique,
View Answer branch_name varchar(15) not null,
balance number not null,
Answer: b primary key(account_number));
Explanation: A fuzzy checkpoint is a create table branch
checkpoint where transactions are allowed (branch_name varchar(15) not null
to perform updates even while buffer blocks
unique,
are being written out.
branch_city varchar(15) not null,
10. If the database modifications occur
assets number not null,
while the transaction is still active, the
primary key(branch_name));
transaction is said to use the
__________ modification technique create table customer
a) Deferred (customer_name varchar(15) not null
b) Immediate unique,
c) More than one of the mentioned customer_street varchar(12) not null,
d) None of the mentioned customer_city varchar(15) not null,
View Answer primary key(customer_name));
Answer: b create table loan
Explanation: If the database modifications (loan_number varchar(15) not null
occur while the transaction is still active, the unique,
transaction is said to use the immediate
branch_name varchar(15) not null,
modification technique. Deferred
modification has overhead whereas amount number not null,
immediate modification doesn’t have any primary key(loan_number));
overhead.
create table depositor insert into customer values (‘McBride’,
(customer_name varchar(15) not null, ‘Safety’, ‘Rye’);
account_number varchar(15) not null,
insert into branch values (‘Downtown’,
primary key(customer_name,
account_number), ‘Brooklyn’, 900000);
insert into branch values (‘Redwood’,
foreign key(account_number) references
account(account_number), ‘Palo Alto’, 2100000);
insert into branch values (‘Perryridge’,
foreign key(customer_name) references
customer(customer_name)); ‘Horseneck’, 1700000);
insert into branch values (‘Mianus’,
create table borrower ‘Horseneck’, 400200);
(customer_name varchar(15) not null, insert into branch values (‘Round Hill’,
loan_number varchar(15) not null, ‘Horseneck’, 8000000);
primary key(customer_name, insert into branch values (‘Pownal’,
loan_number), ‘Bennington’, 400000);
foreign key(customer_name) references insert into branch values (‘North Town’,
customer(customer_name), ‘Rye’, 3700000);
foreign key(loan_number) references insert into branch values (‘Brighton’,
loan(loan_number)); ‘Brooklyn’, 7000000);
insert into branch values (‘Central’,
NOTE: Please insert the following data ‘Rye’, 400280);
into the database for the execution of
further queries. insert into account values (‘A-101’,
‘Downtown’, 500);
insert into customer values (‘Jones’, insert into account values (‘A-215’,
‘Main’, ‘Harrison’); ‘Mianus’, 700);
insert into customer values (‘Smith’, insert into account values (‘A-102’,
‘Main’, ‘Rye’); ‘Perryridge’, 400);
insert into customer values (‘Hayes’, insert into account values (‘A-305’,
‘Main’, ‘Harrison’); ‘Round Hill’, 350);
insert into customer values (‘Curry’, insert into account values (‘A-201’,
‘North’, ‘Rye’); ‘Perryridge’, 900);
insert into customer values (‘Lindsay’, insert into account values (‘A-222’,
‘Park’, ‘Pittsfield’); ‘Redwood’, 700);
insert into customer values (‘Turner’, insert into account values (‘A-217’,
‘Putnam’, ‘Stamford’); ‘Brighton’, 750);
insert into customer values (‘Williams’, insert into account values (‘A-333’,
‘Nassau’, ‘Princeton’); ‘Central’, 850);
insert into customer values (‘Adams’, insert into account values (‘A-444’,
‘Spring’, ‘Pittsfield’); ‘North Town’, 625);
insert into customer values (‘Johnson’,
‘Alma’, ‘Palo Alto’); advertisement
insert into customer values (‘Glenn’,
‘Sand Hill’, ‘Woodside’); insert into depositor values
insert into customer values (‘Brooks’, (‘Johnson’,’A-101′);
‘Senator’, ‘Brooklyn’); insert into depositor values (‘Smith’, ‘A-
insert into customer values (‘Green’, 215’);
‘Walnut’, ‘Stamford’); insert into depositor values (‘Hayes’, ‘A-
insert into customer values (‘Jackson’, 102’);
‘University’, ‘Salt Lake’); insert into depositor values (‘Hayes’, ‘A-
insert into customer values (‘Majeris’, 101’);
‘First’, ‘Rye’); insert into depositor values (‘Turner’, ‘A-
305’);
insert into depositor values
(‘Johnson’,’A-201′); This set of RDBMS Multiple Choice
insert into depositor values (‘Jones’, ‘A- Questions & Answers (MCQs) focuses
217’); on “SQL Queries – I”.
insert into depositor values (‘Lindsay’,’A-
222′); 1. List all branch names and their
assests
insert into depositor values (‘Majeris’,’A-
333′); View Answer
insert into depositor values (‘Smith’, ‘A- Answer: select branch_name, assets from
444’); branch;
2. List all accounts of Brooklyn branch
insert into loan values (‘L-17’, View Answer
‘Downtown’, 1000);
insert into loan values (‘L-23’, Answer: select account_number from
‘Redwood’, 2000); account natural join branch where
insert into loan values (‘L-15’, branch_city=’Brooklyn’;
‘Perryridge’, 1500); 3. List all loans with amount > 1000.
insert into loan values (‘L-14’, View Answer
‘Downtown’, 1500); Answer: select * from loan where
insert into loan values (‘L-93’, ‘Mianus’, amount>1000;
500); 4. List all accounts of Perryridge branch
insert into loan values (‘L-11’, ‘Round with balance < 1000.
Hill’, 900); View Answer
insert into loan values (‘L-16’,
Answer: select account_number from
‘Perryridge’, 1300);
account where branch_name=’Perryridge’
insert into loan values (‘L-20’, ‘North and balance < 1000;
Town’, 7500); 5. List Numbers of accounts with
insert into loan values (‘L-21’, ‘Central’, balances between 700 and 900
570); View Answer
insert into borrower values (‘Jones’, ‘L- Answer: select count(account_number) from
17’); account where balance > 700 and balance <
insert into borrower values (‘Smith’, ‘L- 900;
23’); 6. Change the assests of Perryridge
insert into borrower values (‘Hayes’, ‘L- branch to 340000000.
15’); View Answer
insert into borrower values (‘Jackson’,
‘L-14’); Answer: update branch set assets =
340000000 where
insert into borrower values (‘Curry’, ‘L-
branch_name=’Perryridge’;
93’);
7. Transfer the accounts and loans of
insert into borrower values (‘Smith’, ‘L-
Perryridge branch to Downtown branch.
11’);
View Answer
insert into borrower values (‘Williams’,’L-
17′); Answer: update account set
insert into borrower values (‘Adams’, ‘L- branch_name=’Downtown’ where
16’); branch_name=’Perryridge’;
insert into borrower values (‘McBride’, update loan set branch_name=’Downtown’
where branch_name = ‘Perryridge’;
‘L-20’);
insert into borrower values (‘Smith’, ‘L- 8. Transfer Rs. 100 from account A-101
21’); to A-215.
View Answer
Answer: update account
RDBMS Questions and set balance = case
Answers – SQL Queries – I when account_number=’A-101′ then
balance-100 3. Change the size of the branch_city to
when account_number=’A-215′ then varchar(20).
balance+100 View Answer
else balance
end; Answer: ALTER TABLE branch ALTER
9. Delete the branch Perryridge. COLUMN branch_city type varchar(20);
View Answer 4. Drop the column phoneNo from
customer table.
Answer: delete from account where View Answer
branch_name=’Perryridge’;
delete from branch where Answer: ALTER TABLE customer drop
branch_name=’Perryridge’; phoneNo;
delete from loan where 5. For all customers who have a loan
branch_name=’Perryridge’; from the bank, find their names, loan
10. Waive off all the loans with amount < numbers, and loan amount.
1000. View Answer
View Answer
Answer: select
Answer: delete from borrower where customer_name,loan_number,amount from
loan_number in borrower
(select loan_number from loan where natural join loan;
amount<1000); 6. Find the customer names, loan
delete from loan where amount<1000; numbers, and loan amounts, for all
loans at the Perryridge branch.
View Answer
RDBMS Questions and
Answer: select
Answers – SQL Queries – II customer_name,loan_number,amount from
depositor
This set of RDBMS Questions and natural join loan where
Answers for Campus interviews focuses loan.branch_name=’Perryridge’;
on “Sql Queries – II”. 7. For all customers who have a loan
1. Delete the accounts and loans of from the bank, find their names and loan
Downtown branch. numbers with the attribute loan_number
View Answer replaced by loan_id.
View Answer
Answer: delete from depositor where
account_number IN Answer: select
(select account_number from account where customer_name,loan_number as
branch_name=’Downtown’); loan_id,amount from depositor
delete from account where natural join loan;
advertisement
branch_name=’Downtown’;
delete from borrower where 8. Find the names of all branches that
loan_number IN have assets greater than atleast one
(select loan_number from loan where branch located in Brooklyn.
branch_name=’Downtown’); View Answer