Data Base System Lecture 9: Rational Algebra and Relational Calculus By: Nur Uddin, Ph.D
What will we learn? The meaning of the term “relational completeness.” How to form queries in the relational algebra. How to form queries in the tuple relational calculus. How to form queries in the domain relational calculus. The categories of relational Data Manipulation Languages (DMLs).
Motivation We concentrate on the relational algebra and the relational calculus as defined by Codd (1971) as the basis for relational languages. We may describe the relational algebra as a (high-level) procedural language: it can be used to tell the DBMS how to build a new relation from one or more relations in the database. We may describe the relational calculus as a nonprocedural language: it can be used to formulate the definition of a relation in terms of one or more database relations.
Motivation (cont’d) Both the algebra and the calculus are formal, non-user-friendly languages. They have been used as the basis for other, higher-level Data Manipulation Languages (DMLs) for relational databases.
The 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). The five fundamental operations in relational algebra Selection Projection Cartesian product Union Set difference
Unary and binary operations The Selection and Projection operations are unary operations, as they operate on one relation. The other operations work on pairs of relations and are therefore called binary operations.
Unary operations: selection and projection
Relation: Staff
Selection
Projection
Binary operation Union Set difference Intersection Cartesian product.
Union
Set difference
Intersection
Cartesian product
Cartesian product
Cartesian product
The relational calculus The relational calculus is not related to differential and integral calculus in mathematics, but takes its name from a branch of symbolic logic called predicate calculus. When applied to databases, it is found in two forms: tuple relational calculus, as originally proposed by Codd (1972a), and domain relational calculus, as proposed by Lacroix and Pirotte (1977). The relational calculus is related to discrete mathematics.