1,825 views
0 votes
0 votes

Information about a collection of students is given by the relation studInfo (studId, name, sex). The relation enroll (studId, courseId) gives which student has enrolled for (or taken) what course(s). Assume that every course is taken by EXACTLY one male and EXACTLY one female student. What does the following relational algebra expression represent?


πcourceId((πstudId(σsex="female"(studInfo))×πcourseId(enroll))−enroll)

  1. Courses in which all the female students are enrolled.
  2. Courses in which a proper subset of female students are enrolled.
  3. Courses in which only male students are enrolled.
  4. None of the above

1 Answer

Best answer
1 votes
1 votes
STUDINFO
StudID Name Sex
S1 A Male
S2 B Female
S3 C Female
Enroll
StudID CourseID
S1 C1
S2 C1
S1 C2
S3 C2

ALGEBRA : =  π  courseID ( π studID (σ sex="female" ( STUDINFO )) × π courseID ( enroll )) − enroll )

From  the highlighted part  : We are taking Cartesian product of all FEMALE STUDENTS from STUDINFO table with all COURSES in Enroll Table.

The table will look like:

Cross Product
StudID CourseID
S2 C1
S2 C2
S3 C1
S3 C2

Then We are subtracting Enroll from above table. 

Note: Subtraction of Table P with Table Q contains all the tuples which are in P but not in Q. Example: P = {1,2,3} and Q = {2,3,6}  then P - Q = {1}

The resultant Table from Cross Product  MINUS  Enroll will look like:

Result
StudID CourseID
S2 C2
S3 C1

Now we are selecting CourseID from above Table

Selected Courses : C1 and C2 

Option A) Courses in which all the female students are enrolled =  False because only S2,S1 joined C1 and only S3,S1 joined C2 where S1 is Male.

Option B) Courses in which a proper subset of female students are enrolled.   = TRUE

Option C) Courses in which only male students are enrolled.= False because S2 along with S1 also joined C1 and S3 along with S1 also joined C2

Option B is correct.

selected by

Related questions

0 votes
0 votes
1 answer
2
Ashutosh_17 asked Mar 30, 2023
1,010 views
Let R be a relation of degree 5 then the total number of projections possible on R is ___?