We have following three tables:
- Defender(name, rating, side, goals) --- We get all the defenders name
- Forward(name, rating, assists, goals) --- We get all the forwards name
- Team(name, club, price) -- we get all the players with respect to Team
every name occurring in Team appears in either Defender or Forward
We need to represent this statement in relational algebra expressions.
So I need to pick each player from a team, then I need to verify that whether the name is in Defender table or Forward Table.
This is something like
// i used for Team table, j used for Deferder table and k used for forwards table.
p,q,r are represents respective table sizes
for(i=0;i<p;i++)
{
found_in_defender=0, found_in_forward=0;
for(j=0;j<q;j++){
if(T[i]==D[j]){
found_in_defender=1;
break;
}
}
if(found_in_defender!=1){
for(k=0;k<r;k++){
if(T[i]==F[k]){
found_in_forward=1;
break;
}
}
if(found_in_forward!=1)
printf("Person neither found in Defender nor Forward tables");
}
}Please note that, player is not required to be in the both Defender or Forward tables.
That is equivalent to: $[Team - (Defender \cup Forward)] = \phi$
Now, coming to the options, I don't know what is that operator used in the options.
But I noticed that, there is a intersection between Defender or Forward tables in two options i.e., option A and Option B.
As our requirement is either player should be in Defender or Forward but not player should be in Defender and Forward tables. Whatever may be the operator (consider standard operators like union, intersection, difference, division etc) that works on players who are in Defender and Forward, will not satisfy our requirements.
\( \therefore \text{Eliminate option A and option B} \Rightarrow \text{either option C or option D is the answer}\)
I noticed that, there is a union between Defender or Forward tables in both the options i.e., option C and Option D.
However, option D checking in reverse way. I mean, it is picking each player in the Defender table checking whether player is in the team table or not. Then picking each player in the Forward table checking whether player is in the team table or not. This ensure that whether every player from Defender or Forward table is in the team or not. But our requirement is every person listed in Team appears in either Defender or Forward tables or not. Hence, Option D is not correct choice.
Coming to Option C, the operator look like set difference and it will satisfy our requirements
\( \therefore \text{option C is the correct answer} \)