Você está na página 1de 11

DATABASE MANAGEMENT SYSTEM

Tuple relational calculas


Domain relational calculas

TUPLE RELATIONAL CALCULAS


It is a non procedural language
It describe the desired information using symbols
without giving a specific procedure
for obtaining that information
The query can be expressed as

{t/p(t)}
t is a set of tuples such that the predicate
is true for the tuple t

LOAN RELATION
lno

bname

amount

11
12
13
14

Round hill
Downtown
Perryridge
Perryridge

900
1500
1500
1300

BORROWER AND DEPOSITOR RELATION


cname

Acno

Hayes
Johnson
Jones
Lindsay

102
101
201
217

cname

Lno

Adams
Curry
Hayes
Johnson
jackson

16
93
15
12
14

THERE EXISTS

Suppose we want only the lno attribute, rather


than all the attributes of the loan relation. To
express this request we need the construcut
there exists( ) clause from mathematical logic
t r(q(t))
There exists a tuple t is relation r such that the
predicate q(t) is true

EXAMPLE QURIES
The above depositor and borrower relation is use these
queries
o
Find the name of all customer who have loan from the
perryridge branch
{t / s borrower (s[cname]=t[cname])^ u
loan(u[lno]=t[lno])^(u[branch]=perryridge)}
It require two there exists clause that are connected by
AND(v) symbol
o Find the name of all customer who have loan an accont
or both at the bank
{t / s deposit (s[cname]=t[cname])v u borrower
(u[cname]=t[cname])}
If we want only these customer who have both an account
and a loan at the bank
o

DOMAIN RELATIONAL CALCULAS


Domain relational calculas uses domain variable
that take on value from attributes domain rather
than the value of an entire tuple
An expression in the domain relational calculas is
of the form
{<x1,x2......xn>/p(x1,x2,x3xn)}
Where x1,x2..xn represent the attribute of
the relation .p represent the formula composed of
atom.

FORMS

<x1,x2..xn>tr
where r is a relation on n attribute and x1,x2..xn
are domain variables
x y
x , y are domain variable is the comparision
operator
x c
where x is a domain variable is the comparision
operator and c is a constant

RULES
we built-up formula from atom by the following rule
If p1 is a formula then p1 is also formula
If p1,p2 are formula then p1Vp2,p1^ p2 ,p1 p2
also a formula
P1(x)is a formula then
x p1(x), x p1(x) for also
a formula

EXAMPLE QURIES
The above depositor and borrower relation use
these queries
Find the lno ,bname and amount for loan of over
1200
{<l,b,a>/<l,b,a> loan^a>1200}
o Find the name of all customer who have a loan,an
account are both at a perryridge branch
{<c>/ < l,c> borrower^ b,a<l,b,a> loan ^
b=perryridge} v n <n,c> depositor ^ b,a
<n,b,a> account ^ b=perryridge}

SAFETY OF EXPRESSION
A tuple relational calculas may generate
an infinite relation suppose we write the expression
{t/(t loan)}
there are infinetly many tuples that are not in loan
tables it is unsafe

Você também pode gostar