Relational Calculus: Predicate, Tuple and Domain, Slides of Database Management Systems (DBMS)

An introduction to relational calculus, a formal language used in database systems for querying data. The topics covered include predicate calculus, tuple relational calculus (trc), and domain relational calculus (drc). Predicate calculus deals with truth-valued functions (predicates) and their logical connections using and, or, not, and if-then. Trc focuses on finding tuples for which a predicate is true, while drc uses variables that take values from domains of attributes. Examples and explanations of each concept.

Typology: Slides

2012/2013

Uploaded on 05/06/2013

anuragini
anuragini 🇮🇳

4.4

(14)

134 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Relational Calculus
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Relational Calculus: Predicate, Tuple and Domain and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Relational Calculus

Introduction

  • Relational Calculus is a formal non-procedural language that uses predicates.

Predicate Calculus

  • Predicate – A truth-valued function with arguments.
  • Example:

{ x | P (x) }

“For the set of all x such that P is true for x .”

Predicate Calculus

  • Expressions are constructed from well-formed formulas (WFFs).
  • WFF – An expression composed of atomic predicates.
  • Predicates may be connected by using logical connectives: ∧ (AND), ∨ (OR), ¬ (NOT), and ⇒ (if-then).

Tuple Relational Calculus

  • Finding tuples for which a predicate is true.
  • Example:

“Find the set of all tuples S such that F ( S ) is true”

7

{ S | F ( S ) }

Tuple Relational Calc.

  • Tuple variables on the left side of the bar “|” are called free variables.
  • Tuple variables on the right side of the bar “|” must be bound variables, qualified by ∀ or ∃.

More TRC Examples

  • List the names of staff who do not manage any properties. (Two ways)

10

{S.fName, S.lName | Staff(S) ∧ (¬ ( ∃ P) (PropertyForRent(P) ∧ (S.StaffNo = P.StaffNo)))}

{S.fName, S.lName | Staff(S) ∧ (( ∀ P) (¬PropertyForRent(P) ∨ ¬(S.StaffNo = P.StaffNo)))}

Domain Relational Calculus

  • In DRC, variables take their values from domains of attributes rather than tuples of relations.
  • Somewhat similar to Π in Relational Algebra.

{d 1 , d 2 ,…,dn | F (d 1 ,d 2 ,…,dm)}, m ≥ n

Scope in DRC

  • Important to restrict the scope of your variables, since they are all initially free.
  • Ways of restricting your scope:

(a, b) ∈ R , variable a and b belong to relation R.

Using a Scope

  • Example: Staff(name, age, rank) Family(name, age, relation)

{ name | (name = “Mike”) },

14

This will look in both Staff and Family relations.

{name | name ∈ Staff ∧ name = “Mike” } Looks in only Staff