CSC 480 · Database Management
Our notes
2 min readIdea
Operations take one or two relations and return a relation, so they can be combined (closure). It is procedural: it says how to build the answer step by step. Query optimisers use it internally.
Basic operations
| Operation | Symbol | Result |
|---|---|---|
| Selection | σ_condition(R) | rows of R meeting the condition |
| Projection | π_attributes(R) | chosen columns (duplicates removed) |
| Union | R ∪ S | rows in R or S (union-compatible: same attributes and domains) |
| Set difference | R − S | rows in R but not S |
| Cartesian product | R × S | every row of R paired with every row of S |
| Rename | ρ | new name for a relation or attributes |
Derived operations
- Intersection: R ∩ S = R − (R − S).
- Theta join: R ⋈_θ S = σ_θ(R × S).
- Equijoin: a theta join with equality.
- Natural join R ⋈ S: equijoin on all common attributes, with one copy of each.
- Outer joins (left, right, full): keep unmatched rows, filling the other side with nulls.
- Semijoin: rows of R that have a match in S.
- Division R ÷ S: values in R related to every value in S ("students who registered all 400-level CSC core courses").
Worked queries (running database)
- Names of 400-level students:
π_FirstName,Surname(σ_Level=400(Student)).
- Titles of courses offered by the Computer Science department:
π_Title(σ_DeptName='Computer Science'(Course ⋈ Department)).
- MatNos of students who registered CSC 480 but not CSC 498:
π_MatNo(σ_CourseCode='CSC 480'(Registration)) − π_MatNo(σ_CourseCode='CSC 498'(Registration)).
- Students who registered every course in a set C (CourseCode only):
π_MatNo,CourseCode(Registration) ÷ C.
Small numeric check
If R has 3 rows and S has 4 rows, R × S has 12 rows, and a natural join has between 0 and 12. Selection never increases the row count; projection can reduce it (duplicates removed).
Aggregation (extended algebra)
γ_DeptCode; COUNT(MatNo)(Student): number of students per department. Grouping and aggregates are not in Codd's original algebra but are standard extensions (they map to SQL GROUP BY).
Exams usually ask: define each operator; write algebra expressions for English queries; show the result of an expression on small tables; explain the natural join and division; union compatibility.
Common mistake: applying union or difference to relations with different attributes. They must be union-compatible: project both to the same columns first.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Relational algebra
(opens en.wikipedia.org in a new tab)
Wikipedia, Relational algebra, CC BY-SA 4.0 · licence
Watch
-
Best pick Basics of Relational Algebra
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
Relational Algebra Operations - Unary
15 min · ≈ 68 MB · about ₦38
(opens youtube.com in a new tab)
-
Relational Algebra Queries (Part 1)
22 min · ≈ 99 MB · about ₦56
(opens youtube.com in a new tab)
-
Lec-50: Introduction to Relational Algebra | Database Management System
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
#01 - Relational Model & Algebra (CMU Intro to Database Systems)
1 h 15 min · ≈ 338 MB · about ₦190
(opens youtube.com in a new tab)
-
CMU Database Systems - 02 Relational Algebra (Fall 2017)
1 h 21 min · ≈ 365 MB · about ₦205
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.