Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the schema CR is as given below. $$\begin{array}{|c|c|} \hline \textbf{StudentName} & \textbf {CourseName} \\\hline \text {SA} & \text{CA} \\\hline \text{SA} & \text{CB}\\\hline \text{SA} & \text{CC} \\\hline \text{SB} & \text{CB} \\\hline \text{SB}& \text{CC} \\\hline \text{SC} & \text{CA}\\\hline \text{SC}&\text{CB} \\\hline \text{SC} & \text{CC} \\\hline \text {SD} & \text{CA} \\\hline \text{SD} & \text{CB}\\\hline \text{SD} & \text{CC} \\\hline \text{SD} & \text{CD} \\\hline \text{SE}& \text{CD} \\\hline \text{SE} & \text{CA}\\\hline \text{SE}&\text{CB} \\\hline \text{SF}& \text{CA} \\\hline \text{SF} & \text{CB }\\\hline\text{SF} & \text{CC} \\\hline \end{array}$$ The following query is made on the database.
The number of rows in $T2$ is ______________ .
How many Students have enrolled in all the same courses that Student “SA” has enrolled in : SA enrolled in CA, CB, CC courses → $T1 = \{ CA, CB, CC \}$ from Course table we apply division operator since we want “all” students who enrolled in $T1$ $ = \frac{CR}{T1}$ SA → {CA , CB, CC} $\supseteq T1$ → (1) SB → {CB, CC} $\nsupseteq T1$ SC → {CA , CB, CC} $\supseteq T1$ → (2) SD → {CA , CB, CC, CD} $\supseteq T1$ → (3) SE → {CA , CB, CD} $\nsupseteq T1$ SF → {CA , CB, CC} $\supseteq T1$ → (4) So 4 Out of 6 students are enrolled in ALL courses enrolled by Student SA
ANS) 4
T1 WILL GIVE :- $\begin{array}{|c|c|c|} \hline \text {1. CA} \\\hline \text {2. CB} \\\hline \text {3. CC} \\\hline \end{array}$
T2 = CR $\div$ T1 $=$ All the tuples in CR which are matched with every tuple in T1 : $\begin{array}{|c|c|c|} \hline \text {1. SA} \\\hline \text {2. SC} \\\hline \text {3. SD} \\\hline \text{4. SF} \\\hline \end{array}$
//SB IS NOT MATCHED WITH CA, SE IS NOT MATCHED WITH CC
The values taken in T2 will be the tuples in CR which matches with every tuple in T1
SA matches with
SB matches with only CB CC but not CA so it has not been taken
Similarly, SC matches with all the tuples in T1 CA, CB and CC so it has been taken
SD matches with all the tuples in T1 CA,CB and CC so it has been taken. Since, CD is not in table T1 so it doesn't affect.
SE doesn't match with every tuple in T1, it matches only with CA, CB(in T1) and CD but CD is not present in T1.
SF matches with all the tuples present in T1 so it has also been taken.
plz make me correct if i m wrong.....
64.3k questions
77.9k answers
244k comments
80.0k users