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.
The number of rows in is ______________ .
View worked solution
Answer: 4
To find the number of rows in , let us evaluate the relational algebra operations step-by-step.
Step 1: Evaluate
The query for is:
This selects all courses taken by the student SA. Looking at the relation , the courses associated with SA are:
- CA
- CB
- CC
Thus, .
Step 2: Evaluate
The query for is:
The division operator () finds all StudentName values in that are associated with every CourseName present in . In other words, we need to find students who have registered for at least all three courses: CA, CB, and CC.
Let's list the set of courses taken by each student in :
- SA: — Contains
- SB: — Does not contain
- SC: — Contains
- SD: — Contains
- SE: — Does not contain
- SF: — Contains
The students who satisfy the condition are SA, SC, SD, and SF.
Therefore, the relation is:
The number of rows in is 4.
Free practice · Your answers on this page are not saved.
