0% found this document useful (0 votes)
170 views15 pages

Tuple and Domain

The document discusses domain relational calculus, which uses domain variables that take on values from attribute domains rather than entire tuples. It also provides examples of domain relational calculus queries over bank database relations.

Uploaded by

Vasantha Kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views15 pages

Tuple and Domain

The document discusses domain relational calculus, which uses domain variables that take on values from attribute domains rather than entire tuples. It also provides examples of domain relational calculus queries over bank database relations.

Uploaded by

Vasantha Kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Domain Relational Calculus

 domain relational calculus, uses domain


variables that take on values from an
attributes domain, rather than values for an
entire tuple
 Formal Definition
An expression in the domain relational
calculus is of the form
{< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
where x1, x2, . . . , xn represent domain
variables. P represents a formula composed
of atoms, as was the case in the tuple
relational calculus.

atabase System Concepts - 5th Edition, June 15, 2005 2.1 ©Silberschatz, Korth and Sudarshan
Domain Relational Calculus
 An atom in the domain relational calculus has one of the
following forms:
 < x1, x2, . . . , xn > € r, where r is a relation on n
attributes and x1, x2, . . . , xn are domain variables or
domain constants.
 x Θ y, where x and y are domain variables and Θ is a
comparison operator (<, ≤, =, =, >, ≥). We require that
attributes x and y have domains that can be compared
by Θ.
 x Θ c, where x is a domain variable, Θ is a comparison
operator, and c is a constant in the domain of the
attribute for which x is a domain variable.

atabase System Concepts - 5th Edition, June 15, 2005 2.2 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)

Find the loan number, branch name, and amount


for loans of over $1200:

atabase System Concepts - 5th Edition, June 15, 2005 2.3 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)

Find the loan number, branch name, and amount


for loans of over $1200:

atabase System Concepts - 5th Edition, June 15, 2005 2.4 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)

Find all loan numbers for loans with an amount


greater than $1200:

atabase System Concepts - 5th Edition, June 15, 2005 2.5 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)

Find all loan numbers for loans with an amount


greater than $1200:

atabase System Concepts - 5th Edition, June 15, 2005 2.6 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the names of all customers who have a loan from the
Perryridge branch and find the loan amount:

atabase System Concepts - 5th Edition, June 15, 2005 2.7 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the names of all customers who have a loan from the
Perryridge branch and find the loan amount:

atabase System Concepts - 5th Edition, June 15, 2005 2.8 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the names of all customers who have a loan, an
account, or both at the Perryridge branch:

atabase System Concepts - 5th Edition, June 15, 2005 2.9 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the names of all customers who have a loan, an
account, or both at the Perryridge branch:

atabase System Concepts - 5th Edition, June 15, 2005 2.10 ©Silberschatz, Korth and Sudarshan
Tuple Relational Calculus
 The tuple relational calculus, is a nonprocedural
query language. It describes the desired information
without giving a specific procedure for obtaining that
information.
 A query in the tuple relational calculus is expressed
as
{t | P(t)}
that is, it is the set of all tuples t such that predicate
P is true for t.

atabase System Concepts - 5th Edition, June 15, 2005 2.11 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the branch-name, loan-number, and amount for loans of
over $1200:

atabase System Concepts - 5th Edition, June 15, 2005 2.12 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)

Find the loan number for each loan of an amount greater


than $1200”

atabase System Concepts - 5th Edition, June 15, 2005 2.13 ©Silberschatz, Korth and Sudarshan
Example Queries
 branch (branch_name, branch_city, assets)
 customer (customer_name, customer_street,
customer_city)
 account (account_number, branch_name, balance)
 loan (loan_number, branch_name, amount)
 depositor (customer_name, account_number)
 borrower (customer_name, loan_number)
Find the names of all customers who have a loan from the
Perryridge branch

atabase System Concepts - 5th Edition, June 15, 2005 2.14 ©Silberschatz, Korth and Sudarshan
The End

atabase System Concepts - 5th Edition, June 15, 2005 2.15 ©Silberschatz, Korth and Sudarshan

You might also like