1. Gyanastra
  2. Database Systems
  3. Relational Algebra
  4. Relational Algebra vs Relational Calculus Overview
Free lesson, no account needed 4 min read 8 practice questions after it
Asked in past papers3 times
  • GATE CSE2002
  • UGC NET20192016

Database Systems · Relational Algebra

Relational Algebra vs Relational Calculus Overview

Overview

Relational algebra and relational calculus are the two basic theoretical languages, or sets of operations, used on the relational model before SQL. Understanding how they work on the relational model builds the foundation for designing and using SQL on an RDBMS. They are different from each other, and SQL is derived as a combination of the two.

Key concepts

  • Relational algebra and relational calculus: two basic theoretical languages, or two basic sets of operations, applied to the relational model before SQL.
  • Table as a set: in these languages a table is viewed as a set, and the operations are the set operations possible on that relation.
  • Complementary viewpoints: the two approaches form a pair of complementary viewpoints — algorithm and implementation, conceptual and reality, theory and practical.
  • Relational algebra: requires specifying both what is wanted and how to get it.
  • Relational calculus: requires specifying only what is wanted, without specifying how to get it.
  • SQL: derived as a combination of relational algebra and relational calculus.
  • GATE importance: relational algebra is more important than relational calculus for GATE, although both are studied.
Figure. Algebra is how, calculus is what

How it works

  1. Before moving to SQL, relational algebra and relational calculus are introduced as the foundational operation sets for the relational model.
  2. The relational model is treated as a set of tuples/relations, so the operations studied are set-based operations.
  3. The two languages are then contrasted by their specification style: algebra gives what and how, calculus gives what only.
  4. SQL is understood as a combination of both languages.

Comparison

AspectRelational AlgebraRelational Calculus
SpecificationSpecifies both what we want and how we want itSpecifies only what we want, not how we want it
NatureTheoretical language / set of operations on the relational modelTheoretical language / set of operations on the relational model
View of dataTable is viewed as a set; operations are set operationsTable is viewed as a set; operations are set operations
Role in the pairThe algorithm / implementation / practical side of the contrastThe conceptual / theory side of the contrast
Relation to SQLSQL is derived as a combination of relational algebra and relational calculusSQL is derived as a combination of relational algebra and relational calculus
GATE importanceMore important for GATELess important than relational algebra for GATE

Revision summary

  • Relational algebra and relational calculus are two theoretical languages used on the relational model, studied before SQL.
  • A relation/table is treated as a set, and the operations are set operations.
  • Relational algebra = what + how.
  • Relational calculus = what only, not how.
  • SQL is a combination of relational algebra and relational calculus.
  • For GATE, relational algebra carries more importance than relational calculus.

Previous-year exam insights

  • Relational algebra and safe relational calculus have equal expressive power; unrestricted relational calculus is strictly more expressive because it can express unsafe queries (e.g. infinite or non-domain-dependent results).
    Asked inGATE 2002
  • Relational calculus comes in two forms: tuple relational calculus (variables range over tuples) and domain relational calculus (variables range over domain values); both are equivalent to relational algebra when restricted to safe expressions.
  • Relational algebra is a procedural/operational notation: a query is an expression built from basic operators (select, project, union, set difference, Cartesian product, rename) and derived operators (join, intersection, division, outer joins, aggregation).
  • The basic relational algebra operators are select (σ), project (π), union (∪), set difference (−), Cartesian product (×) and rename (ρ); intersection, natural join and division are derived from these.
  • Relational calculus is a non-procedural (declarative) notation based on first-order predicate logic: a query is written as {t | P(t)} (tuple calculus) or {x1,...,xn | P(x1,...,xn)} (domain calculus), with no specification of evaluation order.
  • A relational calculus expression is safe if its result depends only on the values in the database domain (no infinite relations); only safe calculus expressions correspond to relational algebra queries.
    Asked inGATE 2002
Pages 1–2 of 2