Skip to content
Official PYQ · 2011

GATE CS 2011 Q32 — Normal Forms

Explain with AI

Consider a database table T containing two columns X\text{X} and Y\text{Y} each of type integer\text{integer}. After the creation of the table, one record (X=1, Y=1)\text{(X=1, Y=1)} is inserted in the table.

Let MX\text{MX} and MY\text{MY} denote the respective maximum values of X\text{X} and Y\text{Y} among all records in the table at any point in time. Using MX\text{MX} and MY\text{MY}, new records are inserted in the table 128128 times with X\text{X} and Y\text{Y} values being MX+1, 2*MY+1\text{MX+1, 2*MY+1} respectively. It may be noted that each time after the insertion, values of MX\text{MX} and MY\text{MY} change.

What will be the output of the following SQL query after the steps mentioned above are carried out?

SELECT Y FROM T WHERE X=7;
Choose one option
View worked solution

Answer: A

Let us trace the values of XX and YY inserted into the table TT step-by-step.

Initial State (Step 0):
Only one record exists in the table:
(X0,Y0)=(1,1)(X_0, Y_0) = (1, 1)
Here, the maximum values are MX=1MX = 1 and MY=1MY = 1.

Step 1:
New record inserted: (MX+1,2⋅MY+1)=(1+1,2⋅1+1)=(2,3)(MX + 1, 2 \cdot MY + 1) = (1 + 1, 2 \cdot 1 + 1) = (2, 3).
Now, MX=2MX = 2 and MY=3MY = 3.

Step 2:
New record inserted: (2+1,2⋅3+1)=(3,7)(2 + 1, 2 \cdot 3 + 1) = (3, 7).
Now, MX=3MX = 3 and MY=7MY = 7.

Step 3:
New record inserted: (3+1,2⋅7+1)=(4,15)(3 + 1, 2 \cdot 7 + 1) = (4, 15).
Now, MX=4MX = 4 and MY=15MY = 15.

By observing the pattern for the nn-th insertion step:

  • Xn=n+1X_n = n + 1
  • Yn=2n+1−1Y_n = 2^{n+1} - 1

We are looking for the record where X=7X = 7:

Xn=7  ⟹  n+1=7  ⟹  n=6X_n = 7 \implies n + 1 = 7 \implies n = 6

For n=6n = 6, the corresponding value of YY is:

Y6=26+1−1=27−1=128−1=127Y_6 = 2^{6+1} - 1 = 2^7 - 1 = 128 - 1 = 127

Thus, the query SELECT Y FROM T WHERE X=7; will return 127.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Normal Forms questions