Relational Algebra Notes
Relational Algebra Notes
Example: Show student ID and name for students with GPA > 3.7
Query: π sID, sName (σ GPA>3.7 (Students))
Example: List all cities that have both a branch office and property for
rent
Query: π city (Branch) ∩ π city (PropertyForRent)
Example: Names and GPAs of students with HS > 1000 who applied to
CS and were rejected
Query:
sql
CopyEdit
1. Join Operations
Example: Names & GPAs of students with HS > 1000 who applied to
CS and were rejected
Query:
sql
CopyEdit
bash
CopyEdit
π GPA (σ city='ISB' ∧ major='CS' (Students ⋈ Apply ⋈ University))
Equi-Join
scss
CopyEdit
3. Alternate Notations
Main functions:
o COUNT
o SUM
o AVG
o MIN
o MAX
Example: Find the total salary and number of employees in each
branch
scss
CopyEdit
bash
CopyEdit
Q1: List all students who have a GPA greater than 3.5
Query:
bash
CopyEdit
4o