<<Up     Contents

Tuple calculus

The tuple calculus is a calculus that was introduced by Edgar F. Codd as part of the relational model in order to give a declarative database query language for this data model. It formed the inspiration for the database query languages QUEL and SQL of which the latter, although far less faithful to the original relational model and calculus, is now used in almost all relational database management systems as the ad-hoc query language. Along with the tuple calculus Codd also introduced the domain calculus which is closer to first-order logic and showed that these two calculi (and the relational algebra) are equivalent in expressive power.

Definition of the Calculus

The fundamental assumption in this calculus is that variables range over tuples as they are defined in the relational model. (In what follows the term tuple is always used in that meaning) The atoms of our language are going to be statements about such variables and defined by the following context-free grammar:

B ::= (T.A = T.A) | (T.A = C) | R(T)

where T denotes the set of tuple variables, A denotes the set of attribute names, C denotes the set of constant values and R denotes the set of relation names. Examples of atoms are

These atoms may be combined into formulas, as is usual in first-order logic, with the logicial operators ∧ (and), ∨ (or) and ¬ (not), and we can use the existential quantifier (∃) and the universal quantifier (∀) to bind the variables:

F ::= B | ( FF ) | ( FF ) | ¬ F | ∃ T ( F ) | ∀ T ( F )

Examples of formulas:

Note that the last formula states that all books that are written by C. J. Date have as their subject the relational model. As usual we omit brackets if this causes no ambiguity about the semantics of the formula.

We will assume that the quantifiers quantify over the universe of all tuples. It is easy to see that then a closed formula, i.e., a formula with no free variables, is either true or false for a certain database instance. This means that we can already use those to ask boolean queries, i.e., queries that result in either "yes" or "no". If it is not closed then given a database instance a formula defines a set of bindings, i.e., a function b of the free variables to tuples, such that the formula becomes true iff every free variable x in it is replaced with b(x).

A query language should not only make statements about the contents of the database but it should also be able to construct new tuples that are not yet in the database. For this purpose the tuple constructor is introduced that can construct a tuple given a certain variable binding. Its syntax is defined as follows:

K::= ( A:T.A, ..., A:T.A )

Examples of tuple constructors:

The semantics of a tuple constructor is defined as a partial function that maps a variable binding, i.e., a partial function from tuple variables to tuples, to a tuple. In order for this function to be defined the variable binding should satisfy the following constraints:

Finally we define what a query expression looks like:

Q ::= { K | F }

The result of a query { k | f } is the set of tuples that is constructed by the tuple constructor k from all the bindings that make the formula f true. Examples of query expressions are:

Since the result of the tuple constructor is only defined for certain bindings we have to add certain restrictions such that the result of the tupel constructor is defined for all bindings generated by the formula. Fortunately we can decide this as follows.

We define P(f) and N(f) as functions that map a formula f to a set of pairs (t, a) with t a tuple variable and a an attribute name. The intended meaning of these functions is that P(f) contains a pair (t, a) if in all bindings that make f true the variable t is bound to a tuple with an attribute a, and for N(f) this holds if this is the case for all bindings that make f false. The value of these functions can be inductively defined (and therefore computed) as follows:

P( t.a = s.b ) = { (t, a), (s, b) } N( t.a = s.b ) = ∅
P( t.a = c ) = { (t, a) } N( t.a = c ) = ∅
P( r(t) ) = { (t, a) : a is in the header r } N( r(t) ) = ∅
P( fg ) = P(f) ∪ P(g) N( fg ) = N(f) ∩ N(g)
P( fg ) = P(f) ∩ P(g) N( fg ) = N(f) ∪ N(g)
P( ¬ f ) = N(f) N( ¬ f ) = P(f)
P( ∀ t ( f ) ) = { (s, a) ∈ P(f) : st } N( ∀ t ( f ) ) = { (s, a) ∈ N(f) : st }
P( ∃ t ( f ) ) = { (s, a) ∈ P(f) : st } N( ∃ t ( f ) ) = { (s, a) ∈ N(f) : st }

We then call a query expression { k | f } well formed if for every occurrence of t.a in k it holds that (t, a) is in P(f). It will be clear that the result of every well formed query expression is well defined.

Discuss safeness to prevent that the result may be infinite. Actually we should also check if the comparisos are legal according to the schema, but this is not strictly necessary.

Extensions of Tuple Calculus

Linda, extensions by Leler et al)

Glasglow.com

Encyclopedia Search

Add To: LinkarenaAdd To: DiggAdd To: Del.icio.usAdd To: StumbleUponAdd To: YahooAdd To: GoogleAdd To MyspaceAdd To: TwitterAdd To Facebook

Untreated wastewater used
Powell among McCain VP po
Climate expert named good
Gender Differences in the
Pa. man wins ATV in drawi
Thousands displaced by qu
Actor wanted to play Pete
Fox plans Gordon Ramsay c
U.N. ties red meat to glo

Walmart, others cut TV prices
Actor Rip Torn arrested drunk,
Cracking down on TV fake medic
Oscar voters wrestle with best
Reality TV fashion stars find
Cinematographers use tech to b
Pa. man wins ATV in drawing
ATV Adventures offer quad bike
Restaurant owners donate ATV t
How to Purchase and Enjoy ATV
ATV spreading food crops
ATV safety tips
"Complicit" leaves good actors
Fox plans Gordon Ramsay cook-a
"Idol" creator eyes TV version
White House expects digital TV
Danny Boyle wins top director
Meryl Streep wins SAG best act
"60 Minutes" lands hero pilot'
Tom Cruise says grew up wantin
Vatican to get own YouTube cha
Fox eyes more comedies, cancel
Locklear gets probation and fi
John Travolta's Son: Meds Ulti
Spears to 'set the record stra

Guangzhou English ArticlesLanguage as a social conv
Language as a social conv
Language as a social conv
Business English Discussi
Thousands of hyphens peri
Thousands of hyphens peri
Autism gene linked to chi
Autism gene linked to chi
Study takes step toward e
English Lesson No Idioms
Thousands of hyphens perish as
France vintner turns to Intern
Mobiles to have same charging
Asia's shoppers go online as I
Hotmail POP3 From Any Country
S.Korean bio firm says dog clo
Super-rich still want to boldl
Tesco to launch own-brand clot
Human error at Google sends th
Nike CEO sees big jump in onli
Dell plots smartphone foray, e
Japan launches satellites, eye
Challenges loom as Obama seeks
Internet Explorer 7 IE7 And Go
New Yahoo CEO gets $19 million
Heroes tribute odd addition to
Heroes tribute odd addition to
Financial crisis ate your job?
China makes arrests in Interne
LG Display says market hit bot
Previous    Next

Dictionary Search

Trump's "golden" image on tria
Consumers' mood improves sligh
Consumers' mood improves sligh
Consumers' mood improves sligh
Nike CEO sees big jump in onli
Nike CEO sees big jump in onli
U.S. judge says will likely ru
U.S. working to ensure stimulu
Sewage yields more gold than t
Obama pushes economic plan
Jews struggle to come to grips
Pfizer to buy Wyeth for $68 bi
New Yahoo CEO gets $19 million
Financial crisis ate your job?
Almost all U.S. cities to lose
Citi sale could be game-change
Hotel giants seek refuge in ni
Citi breakup in sight after Mo
U.S. arrests wealth manager ac
Chrysler in asset sale talks,
Previous    Next