0
3.2kviews
Explain the following relational algebra operations with proper examples i. Left outer join ii. Division iii. Rename iv. Outer join v. Project
1 Answer
0
30views

Left Outer Join:

  • In left outer join all the tuples of left relation remain part of the output. The tuples that gave a matching tuple in the second relation do have the corresponding tuple from the second relation.
  • However, for the tuples of the left relation, which do not have a matching record in the right tuple have Null values against the attributes of the right relation.

Project Operation (∏)

  • Projects column(s) that satisfy given predicate.
  • Notation: ∏A1, A2, An (r)
  • Where a1, a2, an are attribute names of relation r.
  • Duplicate rows are automatically eliminated, as relation is a set.

    For example:

    ∏subject, author (Books)

    Selects and projects columns named as subject and author from relation Books.

Rename operation ( ρ )

  • Results of relational algebra are also relations but without any name.
  • The rename operation allows us to rename the output relation. Rename operation is denoted with small greek letter rho ρ.
  • Notation: ρ x (E)
  • Where the result of expression E is saved with name of x. Outer Join:
  • In outer join all the tuples of left and right relations are part of the output.
  • It meansthat all those tuples of left relation which are not matched with right relation are left as Null.
  • Similarly all those tuples of right relation which are not matched with leftrelation are left as null.

Division

  • Not supported as a primitive operator, but useful for exressing queries like:
    Find sailors who have reserved all boats.
  • Precondition: in A/B, the attributes in B must be included in the schema for A. Also, the result has attributes A-B.
  • SALES(supId, prodId);
  • PRODUCTS(prodId);
  • Relations SALES and PRODUCTS must be built using projections.
  • SALES/PRODUCTS: the ids of the suppliers supplying ALL products.
Please log in to add an answer.