Question
Consider a database that has the relation schema . An instance of the schema CR is as given below.
| StudentName | CourseName |
|---|---|
| SA | CA |
| SA | CB |
| SA | CC |
| SB | CB |
| SB | CC |
| SC | CA |
| SC | CB |
| SC | CC |
| SD | CA |
| SD | CB |
| SD | CC |
| SD | CD |
| SE | CD |
| SE | CA |
| SE | CB |
| SF | CA |
| SF | CB |
| SF | CC |
The following query is made on the database:
The number of rows in is ______.
Official answer and solution
- Official answer
- 4
- From
- Official GATE 2017 answer key
Solution
Evaluate the relational algebra expression by finding the projection of course names for student SA, then computing relational division .
The first operation finds the set of courses taken by student 'SA':
From the given table, student 'SA' is enrolled in courses: CA, CB, CC.
Thus, .
The second operation is relational division:
By definition, returns all students who are associated with every course in (i.e., students who are enrolled in all three courses CA, CB, and CC).
Check each distinct student in relation CR:
SA: has enrolled in all three Included.SB: has missing CA Not included.SC: has enrolled in all three Included.SD: has contains all three Included.SE: has missing CC Not included.SF: has enrolled in all three Included.
Therefore, contains the 4 students: . The number of rows in is 4.
4.0
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 1
- Question
- 46 of 65, printed as CS Q.46
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.