GateAI
Relational Model and SQL

GATE CSE 2017 Set 1 · Q46

NAT2 marksMedium

Time

Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below. 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 _______.

GATE CSE 2017 Set 1 Q46 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 4 (±0)

Relational Model and SQL

First, evaluate intermediate relation T1T1:

T1 = \pi_{\text{CourseName}}(\sigma_{\text{StudentName} = \text{'SA^{\prime}}}(\text{CR}))

From the given table, for StudentName = 'SA', the courses are:

T1={CA,CB,CC}T1 = \{\text{CA}, \text{CB}, \text{CC}\}

Next, evaluate the relational division T2=CR÷T1T2 = \text{CR} \div T1: The division operator CR÷T1\text{CR} \div T1 selects all distinct StudentName values that are associated with *all* courses present in T1T1 (i.e., CA, CB, and CC).

Let us check the courses taken by each student:

  • SA: {CA, CB, CC} →\rightarrow contains all three courses.

  • SB: {CB, CC} →\rightarrow does not contain CA.

  • SC: {CA, CB, CC} →\rightarrow contains all three courses.

  • SD: {CA, CB, CC, CD} →\rightarrow contains all three courses.

  • SE: {CD, CA, CB} →\rightarrow does not contain CC.

  • SF: {CA, CB, CC} →\rightarrow contains all three courses.

Thus, the students present in T2T2 are SA, SC, SD, and SF.

Therefore, the number of rows in T2T2 is 4 [cite: 2].

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Relational Model and SQL previous year question is Q46 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Relational Model and SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Relational Model and SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Relational Model and SQL in GATE CSE

Relational Model and SQL has 15 GATE CSE PYQs across 12 papers from 2011 to 2026. 2 of them are 2-mark NAT questions like this one, and GATE CSE 2017 Set 1 has 3.

How GATE tests Relational Model and SQL

More from GATE CSE 2017 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 1 · Q46 · NAT

Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below. The following query is made on the database. T1 CourseName ( StudentName = 'SA'(CR)) T2 CR T1 The number of rows in T2 is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.