ISRO Computer Science (CSE) 2023 - Question 30

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 2023

Topic: Database Management Systems

Consider a database table T containing two columns X and Y each of type Integer. After the creation of the table, one record (X=1, Y=1) is inserted in the table. Let MX and MY denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX and MY, new records are inserted in the table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion, values of MX and MY change. What will be the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;

  • A. 127
  • B. 15
  • C. 129
  • D. 257

Answer: A. 127

Explanation: The table starts with X=1, Y=1 (MX=1, MY=1).
Insert 1: X = 1+1 = 2, Y = 2(1)+1 = 3
Insert 2: X = 2+1 = 3, Y = 2(3)+1 = 7
Insert 3: X = 3+1 = 4, Y = 2(7)+1 = 15
Insert 4: X = 4+1 = 5, Y = 2(15)+1 = 31
Insert 5: X = 5+1 = 6, Y = 2(31)+1 = 63
Insert 6: X = 6+1 = 7, Y = 2(63)+1 = 127
The SQL query SELECT Y FROM T WHERE X=7 will return the Y value when X is 7, which is 127.

| | All questions of ISRO Computer Science (CSE) 2023