Databases questions — page 4 of 6

Q12

GATE CS 2018 CSRelational QueriesMCQ1 mark−1/3 if wrong
Consider the following two tables and four queries in SQL.

Book (isbn, bname), Stock (isbn, copies)

Query 1: SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;

Query 2: SELECT B.isbn, S.copies
FROM Book B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;

Query 3: SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;

Query 4: SELECT B.isbn, S.copies
FROM Book B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;

Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Show answer without attempting

Answer: D

Q41

GATE CS 2018 CSRelational QueriesMCQ2 marks−2/3 if wrong
Consider the relations r(A,B)r(A, B) and s(B,C)s(B, C), where s.Bs.B is a primary key and r.Br.B is a foreign key referencing s.Bs.B. Consider the query

Q:r⋈(σB<5(s))Q: r \bowtie (\sigma_{B<5}(s))

Let LOJ denote the natural left outer-join operation. Assume that rr and ss contain no null values.

Which one of the following queries is NOT equivalent to QQ?
Show answer without attempting

Answer: C

Q42

GATE CS 2018 CSRelational DesignMCQ2 marks−2/3 if wrong
Consider the following four relational schemas. For each schema, all non-trivial functional dependencies are listed. The underlined attributes are the respective primary keys.

Schema I: Registration (rollno‾\underline{\text{rollno}}, courses)
Field 'courses' is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency:
rollno →\to courses

Schema II: Registration (rollno, courseid‾\underline{\text{rollno, courseid}}, email)
Non-trivial functional dependencies:
rollno, courseid →\to email
email →\to rollno

Schema III: Registration (rollno, courseid‾\underline{\text{rollno, courseid}}, marks, grade)
Non-trivial functional dependencies:
rollno, courseid →\to marks, grade
marks →\to grade

Schema IV: Registration (rollno, courseid‾\underline{\text{rollno, courseid}}, credit)
Non-trivial functional dependencies:
rollno, courseid →\to credit
courseid →\to credit

Which one of the relational schemas above is in 3NF but not in BCNF?
Show answer without attempting

Answer: B

Q16

GATE CS 2017 CS-1Relational DesignMCQ1 mark−1/3 if wrong
The following functional dependencies hold true for the relational schema R{V,W,X,Y,Z}R\{V, W, X, Y, Z\}:

V→WV \to W
VW→XVW \to X
Y→VXY \to VX
Y→ZY \to Z

Which of the following is irreducible equivalent for this set of functional dependencies?
Show answer without attempting

Answer: A

Q23

GATE CS 2017 CS-1Relational QueriesNAT1 mark
Consider a database that has the relation schema EMP(EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below.
EmpIdEmpNameDeptName
1XYAAA
2XYBAA
3XYCAA
4XYDAA
5XYEAB
6XYFAB
7XYGAB
8XYHAC
9XYIAC
10XYJAC
11XYKAD
12XYLAD
13XYMAE
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
    (SELECT DeptName, COUNT(EmpId) AS
                    EC(DeptName, Num)
     FROM EMP
     GROUP BY DeptName)
The output of executing the SQL query is ____________.
Show answer without attempting

Answer: 2.6

Q41

GATE CS 2017 CS-1Relational QueriesMCQ2 marks−2/3 if wrong
Consider a database that has the relation schemas EMP(EmpId, EmpName, DeptId), and DEPT(DeptName, DeptId). Note that the DeptId can be permitted to be NULL in the relation EMP.
Consider the following queries on the database expressed in tuple relational calculus.

(I) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∀v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \forall v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(II) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]≠v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] \neq v[\text{DeptId}])) \rbrace
(III) {t∣∃u∈EMP(t[EmpName]=u[EmpName]∧∃v∈DEPT(t[DeptId]=v[DeptId]))}\lbrace t \mid \exists u \in \text{EMP}(t[\text{EmpName}] = u[\text{EmpName}] \land \exists v \in \text{DEPT}(t[\text{DeptId}] = v[\text{DeptId}])) \rbrace

Which of the above queries are safe?
Show answer without attempting

Answer: D

Q42

GATE CS 2017 CS-1TransactionsMCQ2 marks−2/3 if wrong
In a database system, unique timestamps are assigned to each transaction using Lamport's logical clock. Let TS(T1)TS(T_1) and TS(T2)TS(T_2) be the timestamps of transactions T1T_1 and T2T_2 respectively. Besides, T1T_1 holds a lock on the resource R, and T2T_2 has requested a conflicting lock on the same resource R. The following algorithm is used to prevent deadlocks in the database system assuming that a killed transaction is restarted with the same timestamp.

if TS(T2)<TS(T1) thenT1 is killedelse T2 waits.\begin{aligned} & \text{if } TS(T_2) < TS(T_1) \text{ then} \\ & \quad T_1 \text{ is killed} \\ & \text{else } T_2 \text{ waits.} \end{aligned}

Assume any transaction that is not killed terminates eventually. Which of the following is TRUE about the database system that uses the above algorithm to prevent deadlocks?
Show answer without attempting

Answer: A

Q46

GATE CS 2017 CS-1Relational QueriesNAT2 marks
Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below.
StudentNameCourseName
SACA
SACB
SACC
SBCB
SBCC
SCCA
SCCB
SCCC
SDCA
SDCB
SDCC
SDCD
SECD
SECA
SECB
SFCA
SFCB
SFCC
The following query is made on the database.

T1←πCourseName(σStudentName=′SA′(CR))T1 \leftarrow \pi_{\text{CourseName}}(\sigma_{\text{StudentName} = '\text{SA}'}(\text{CR}))
T2←CR÷T1T2 \leftarrow \text{CR} \div T1

The number of rows in T2T2 is ____________.
Show answer without attempting

Answer: 4.0

Q17

GATE CS 2017 CS-2Data ModelsMCQ1 mark−1/3 if wrong
An ER model of a database consists of entity types A and B. These are connected by a relationship R which does not have its own attribute. Under which one of the following conditions, can the relational table for R be merged with that of A?
Show answer without attempting

Answer: C

Q19

GATE CS 2017 CS-2Relational DesignNAT1 mark
Consider the following tables T1 and T2.

T1:
PQ
22
38
73
58
69
85
98
T2:
RS
22
83
32
97
57
72
In table T1, P\mathbf{P} is the primary key and Q\mathbf{Q} is the foreign key referencing R\mathbf{R} in table T2 with on-delete cascade and on-update cascade. In table T2, R\mathbf{R} is the primary key and S\mathbf{S} is the foreign key referencing P\mathbf{P} in table T1 with on-delete set NULL and on-update cascade. In order to delete record (3,8)(3,8) from table T1, the number of additional records that need to be deleted from table T1 is ____________.
Show answer without attempting

Answer: 0.0

Q44

GATE CS 2017 CS-2TransactionsNAT2 marks
Two transactions T1T_1 and T2T_2 are given as

<br>T1:r1(X)w1(X)r1(Y)w1(Y)<br>T2:r2(Y)w2(Y)r2(Z)w2(Z)<br>\begin{aligned}<br>T_1 &: r_1(X)w_1(X)r_1(Y)w_1(Y) \\<br>T_2 &: r_2(Y)w_2(Y)r_2(Z)w_2(Z)<br>\end{aligned}

where ri(V)r_i(V) denotes a read operation by transaction TiT_i on a variable VV and wi(V)w_i(V) denotes a write operation by transaction TiT_i on a variable VV. The total number of conflict serializable schedules that can be formed by T1T_1 and T2T_2 is ____________.
Show answer without attempting

Answer: 54.0

Q46

GATE CS 2017 CS-2Relational QueriesNAT2 marks
Consider the following database table named top_scorer.
playercountrygoals
KloseGermany16
RonaldoBrazil15
G MüllerGermany14
FontaineFrance13
PeléBrazil12
KlinsmannGermany11
KocsisHungary11
BatistutaArgentina10
CubillasPeru10
LatoPoland10
LinekerEngland10
T MüllerGermany10
RahnGermany10
Consider the following SQL query:
SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL (SELECT tb.goals
                        FROM top_scorer AS tb
                        WHERE tb.country = 'Spain')
AND ta.goals > ANY (SELECT tc.goals
                    FROM top_scorer AS tc
                    WHERE tc.country = 'Germany')
The number of tuples returned by the above SQL query is ____________.
Show answer without attempting

Answer: 7.0

Q49

GATE CS 2017 CS-2Storage and IndexingNAT2 marks
In a B+ tree, if the search-key value is 8 bytes long, the block size is 512 bytes and the block pointer size is 2 bytes, then the maximum order of the B+ tree is ____________.
Show answer without attempting

Answer: 52.0

Q21

GATE CS 2016 CS-1Relational DesignMCQ1 mark−1/3 if wrong
Which of the following is NOT a superkey in a relational schema with attributes V,W,X,Y,ZV, W, X, Y, Z and primary key VYVY?
Show answer without attempting

Answer: B

Q22

GATE CS 2016 CS-1TransactionsMCQ1 mark−1/3 if wrong
Which one of the following is NOT a part of the ACID properties of database transactions?
Show answer without attempting

Answer: D

Q23

GATE CS 2016 CS-1Relational DesignMCQ1 mark−1/3 if wrong
A database of research articles in a journal uses the following schema.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, YEAR, PRICE)
The primary key is (VOLUME, NUMBER, STARTPAGE, ENDPAGE) and the following functional dependencies exist in the schema.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) →\to TITLE
(VOLUME, NUMBER) →\to YEAR
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) →\to PRICE
The database is redesigned to use the following schemas.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE)
(VOLUME, NUMBER, YEAR)
Which is the weakest normal form that the new database satisfies, but the old one does not?
Show answer without attempting

Answer: B

Q51

GATE CS 2016 CS-1TransactionsMCQ2 marks−2/3 if wrong
Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or write operations), a certain set of objects {O1,…,Ok}\{O_1, \dots, O_k\}. This is done in the following manner:
Step 1. T acquires exclusive locks to O1,…,OkO_1, \dots, O_k in increasing order of their addresses.
Step 2. The required operations are performed.
Step 3. All locks are released.
This protocol will
Show answer without attempting

Answer: A

Q21

GATE CS 2016 CS-2Storage and IndexingMCQ1 mark−1/3 if wrong
B+ Trees are considered BALANCED because
Show answer without attempting

Answer: A

Q22

GATE CS 2016 CS-2TransactionsMCQ1 mark−1/3 if wrong
Suppose a database schedule SS involves transactions T1,…,TnT_1, \dots, T_n. Construct the precedence graph of SS with vertices representing the transactions and edges representing the conflicts. If SS is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule?
Show answer without attempting

Answer: A

Q51

GATE CS 2016 CS-2TransactionsMCQ2 marks−2/3 if wrong
Consider the following database schedule with two transactions, T1T_1 and T2T_2.
S=r2(X);r1(X);r2(Y);w1(X);r1(Y);w2(X);a1;a2S = r_2(X); r_1(X); r_2(Y); w_1(X); r_1(Y); w_2(X); a_1; a_2

where ri(Z)r_i(Z) denotes a read operation by transaction TiT_i on a variable ZZ, wi(Z)w_i(Z) denotes a write operation by TiT_i on a variable ZZ and aia_i denotes an abort by transaction TiT_i.

Which one of the following statements about the above schedule is TRUE?
Show answer without attempting

Answer: C

0/200 correct0 marks

Related topics in GATE CS