0% found this document useful (0 votes)
628 views10 pages

Domain vs Tuple Relational Calculus

The document provides examples and explanations of domain relational calculus concepts. It discusses tuple and domain variables, formulas, queries to retrieve information from relations using calculus, and set operations like divide, minus, and negate. Examples include queries over muppet and ratings relations to illustrate calculus concepts and the use of calculus, QBE, and SQL to retrieve drinkers that frequent certain bars with particular beer preferences.

Uploaded by

Moumita Paul
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
628 views10 pages

Domain vs Tuple Relational Calculus

The document provides examples and explanations of domain relational calculus concepts. It discusses tuple and domain variables, formulas, queries to retrieve information from relations using calculus, and set operations like divide, minus, and negate. Examples include queries over muppet and ratings relations to illustrate calculus concepts and the use of calculus, QBE, and SQL to retrieve drinkers that frequent certain bars with particular beer preferences.

Uploaded by

Moumita Paul
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Domain Relational Calculus [205]

tuple variable domain variables

 r(a1,a2,...an) where a's are variables or constants


 x y where x,y are variables or constants
 (formula)
 formula

 where A is single attribute

Domain Relational Calculus: Example [206]

Query

Get the names of all all frog muppets.

QBE

muppets NAME ANIMAL COLOR


P. frog

Domain

{ ' }
Query

Get shows casting green muppets.

QBE

muppets NAME ANIMAL COLOR


_kermit green
casting NAME SHOW NETWORK
_kermit P.

Domain

' }

Domain Relational Calculus: Divide [207]

certified
PILOT EQUIPMENT
joe 707
joe 727
joe 747
moe 707
doe 707
doe 727
doe 747
doe 1011

equip
EQUIPMENT
707
727
747

PILOT
joe
doe

certified equip says the pilot is certified on ALL equipment

Tuple Relational Calculus: Divide [208]

Query

Get muppets acting in ALL shows on ABC.

Algebra
Tuple

'

'

Tuple Relational Calculus: Minus [209]

Query

Get muppets acting ONLY on shows on ABC.

Algebra

Tuple

')}
Domain

'))}

Tuple Relational Calculus: Minus [210]

Query

Get the highest rank (join with different names).

Algebra

QBE

RATINGS NETWORK RANK


P. _x

_x

SQL
SELECT [Link] FROM ratings r WHERE [Link] NOT IN
SELECT [Link] FROM ratings r1,ratings r2

WHERE [Link] [Link]

Tuple

Tuple

Domain Relational Calculus: Negate [211]

Query

Get muppets acting ONLY on networks not casting Kermit.

Domain

' }
QBE

CASTING NAME NET


_m _n
`Kermit' _n

TEMP NAME
I. _m
TEMP NAME
_m

CASTING NAME NET


_m

RESULT NAME
I. _m

SQL

SELECT [Link] FROM casting c WHERE [Link] NOT IN


SELECT [Link] FROM casting d, casting e
WHERE [Link] = [Link] and [Link] = `Kermit'

Relational Calculus: Examples [212]

Schema

frequents(DRINKER,BAR) serves(BAR,BEER)
likes(DRINKER,BEER)

Query

Get all drinkers who frequent at least one bar that serves a beer they like.
Algebra

Tuple

Domain

Relational Calculus: Examples [213]

Query

Get the drinkers that frequent no bar that serves a beer they like.

Algebra
Domain

SQL

SELECT [Link] FROM frequents f


WHERE [Link] NOT IN
SELECT [Link] FROM frequents g, serves s, likes l
WHERE [Link] = [Link] and [Link] = [Link] and
[Link] = [Link]

Relational Calculus: Examples [214]

Query

Get the drinkers that frequent only bars that serve some beer they like.

Domain

}
Algebra

Algebra

You might also like