Back to the 2021 paper

Unit 2: Relational Query Languages

20217m

Explain the following operations with the help of examples:

  • (i) Set of intersection operation
    (ii) Natural join operation
    (iii) Division operation
Worked SolutionAI Assisted

Relational Algebra Operations with Examples:

(i) Set Intersection: R ∩ S returns tuples present in both relations, requires union compatibility (same arity, domain). Example: Student ∩ CricketTeam gives students who are both enrolled and in cricket team. Can be expressed as R - (R - S).

(ii) Natural Join: Combines tuples from two relations where common attributes have equal values, automatically equating and projecting out duplicate column. Example: Student(sid, name) natural join Enroll(sid, cid) returns (sid, name, cid) where sid matches, without duplicate sid. Equivalent to cross product + selection + projection on equality of common attributes.

(iii) Division: R ÷ S returns values of attributes of R not in S that are associated with all values in S. Used for "for all" queries. Example: Completed(Student, Course) ÷ Required(Course) gives students who completed all required courses. If Completed has (Amit,DBMS),(Amit,OS) and Required has (DBMS),(OS), result is Amit.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.