Week # 15
Relational Algebra
1) Background
* For data manipulation, Dr. Codd suggested two generic languages, both based on mathematical
principles
* The two languages provide well-defined methods to work on rows and columns of tables
* These two languages are called relational algebra and relational calculus
* Both the algebra and calculus are formal, non-user-friendly languages
* No program code is directly written to contain relational algebra and relational calculus commands or
operations. However, popular languages included in commercial database management systems implement
elements of these generic languages
* Structured Query Language (SQL) is one such implementation based on the generic languages, mostly
based on relational calculus
* To understand how data manipulation is made possible in a relational data model, you need to gain a good
understanding of the two generic languages
2) Relational Algebra
* The relational algebra is a theoretical language with operations that work on one or more relations to
define another relation without changing the original relation(s) (or)
* Relational algebra consists of mathematical operations on rows and columns of one or more relations
* The result of an operation is a new relation, which may have been formed from one or more input
relations
* There are several variations of syntax for relational algebra commands
* The five fundamental operations in relational algebra are selection, projection, cartesian product,
union, and set difference
- Perform most of the data retrieval operations
* In addition, there are also the join, intersection, assignment and division operations
* The selection and projection are unary operations, as they operate on single relation
* The other operations work on pairs of relations and are therefore called binary operations
2.a) Selection Operation (σ)
* Operates on a single relation
* Selects specific rows from a relation on the basis of given criteria
* The result is a relation containing rows and columns
- Rows: only the selected rows from the original relation
- Columns: same columns as in the original relation
Dr. Kifayat Ullah Introduction to Database Systems CECOS University Peshawar