### Intro to Relational Calculus

• Relational Calculus: The "other" formal query language for the Relational Model

• Relational Calculus:

• Relational Calculus is the other formal query language that is defined for the Relational Data Model

• In Relational Calculus, a query (= selection of a set of tuples that satisfies a certain condition) is expressed using logical conditions

 In contrast, a query in Relational Algebra is expressed using operations (e.g., join, project, ...

• Therefore:

 Relational Calculus is a non-procedural language,        while Relational Algebra (that we have learned in the previous chapter) is a procedural language

• Teaching note:

 I do not intend to cover Relational Calculus completely I only want to give you a brief intro into the matter. Because ultimately, you will most likely be using SQL --- you don't need Relational Calculus to use SQL effectively. Knowledge of Relational Algebra is sufficient (and probably preferred)

• Tuple variables

• Tuple variable:

• Tuple variable = a variable name that represents tuples in the database

 Relational Calculus typically uses a lower case letter to denote tuple variables

• Examples:

 ``` t s ```

• Query formulation in Relational Calculus

• Queries in Relational Calculus are expressed as follows:

 ``` { t | CONDITION(t) } Meaning: Retrieve all tuples t for which the condition CONDITION(t) is true ```

• Example:

 ``` Relational Calculus expression: { t } output: All tuples in the database ```