A brief overview of the non-procedural relational calculus.
Relational Calculus provides a higher-level, declarative way to specify queries compared to the procedural nature of relational algebra. Instead of describing the steps to get the result, you describe the properties of the result itself. There are two main forms of relational calculus. First is Tuple Relational Calculus (TRC). In TRC, we specify a query by describing the properties of the tuples we want to retrieve. The query is expressed in the form {T | P(T)}, which means 'retrieve all tuples T such that predicate P is true for T'. Here, 'T' is a tuple variable that ranges over the tuples of a relation. For example, to find all employees with a salary over 50000, you would write something like {T | T ∈ Employees AND T.salary > 50000}. SQL is heavily based on TRC. Second is Domain Relational Calculus (DRC). In DRC, variables range over the domains (values) of the attributes rather than over the tuples. The query is expressed as {<x, y, z, ...> | P(x, y, z, ...)}, which means 'retrieve all tuples <x, y, z, ...> such that predicate P is true for the domain variables x, y, z, ...'. For the same salary query, it might look like {<i, n, d, s> | <i, n, d, s> ∈ Employees AND s > 50000}. Both TRC and DRC are computationally equivalent to relational algebra, meaning any query that can be expressed in one can be expressed in the others. They provide the formal, logical foundation for the design of declarative query languages like SQL.