December 17, 2022
Read Time: 4 mins 21 secs
Word Count: 1034
Relational Algebra first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it. The main application of relational algebra is providing a theoretical foundation for relational databases. SQL is based on this theoretical foundation. Relational Algebra is based on set theory. Recursively applying relational algebra to a relation yields intermediate outcomes that are also regarded as relations.
Operations in Relational Algebra are
- Projection
- Selection
- Cartesian Product
- Set Union
- Joins
- Rename operator
Project Operation (∏)
Projection Operator is a relational algebra unary operator that performs a projection operation. It projects column(s) that satisfy a given predicate.
Notation - ∏ A1, A2, An (r)
Example - ∏ trn, order_amount (Order)
SQL – Select trn, order_amount from Order.
OrderID | Order Amount | TRN | TypeId |
---|---|---|---|
B133 | $1000 | 100456 | 1 |
B234 | $2000 | 100234 | 1 |
B335 | $1000 | 100456 | 2 |