ITPEC FE Morning October 2018 Question 29

Topic: Databases

After relations X and Y are joined, which of the following is (are) the relational algebra operation(s) to obtain relation Z?

X

StudentNumberNameFacultyCode
1Amy WhiteA
2Bob GreenB
3Cathy BlackA
4David GreyB
5Edward BrownA
6Frank BlueA

Y

FacultyCodeFacultyName
AEngineering
BInformation
CLiterature

Z

FacultyNameStudentNumberName
Information2Bob Green
Information4David Grey

Explanation

Projection and selection — after the join, selection keeps only the Information rows and projection keeps only three columns.

Joining X and Y on FacultyCode gives six rows with the columns StudentNumber, Name, FacultyCode and FacultyName (faculty C has no students, so it drops out). Relation Z has two rows and three columns:

  • •Selection picks the rows where FacultyName is Information: students 2 and 4
  • •Projection keeps the columns FacultyName, StudentNumber and Name, dropping FacultyCode

Answer (a)

Why not others:

  • •(b) Projection and union — union adds the rows of a second relation with the same columns; it can never reduce six rows to two
  • •(c) Selection — reduces the rows but leaves FacultyCode in the result, which Z does not have
  • •(d) Selection and union — still no projection to remove FacultyCode, and there is no second relation to unite with

Key rule: Selection chooses rows (the WHERE clause), projection chooses columns (the SELECT list), and union combines rows of two compatible relations.

Databases · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.