0% found this document useful (0 votes)
38 views1 page

Relational Language - Tutorial

This document provides a tutorial on relational languages and contains 4 examples of queries on relations. The examples show how to find branch names, loans over $1200, customers with loans or accounts, and customers with loans from the Perryridge branch. Solutions are provided using relational algebra notation and SQL syntax.

Uploaded by

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

Relational Language - Tutorial

This document provides a tutorial on relational languages and contains 4 examples of queries on relations. The examples show how to find branch names, loans over $1200, customers with loans or accounts, and customers with loans from the Perryridge branch. Solutions are provided using relational algebra notation and SQL syntax.

Uploaded by

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

TUTORIAL – 2

Relational Languages

loan (loan_number, branch_name, amount)


depositor (customer_name, account_number)
borrower (customer_name, loan_number)

1. Find the names of all branches in the loan relation:


Solution:

 πbranch_name (loan)
 select branch_name from loan

2. C Find the loan number for each loan of an amount greater than $1200
Solution:
 π loan_number (amount > 1200 (loan))
 Select loan_number from loan where amount>1200;

3. Find the names of all customers who have a loan, an account, or both, from the bank
Solution:
 customer_name (borrower)  customer_name (depositor)
 Select customer_name from borrower

Select customer_name from depositor;

4. Find the names of all customers who have a loan at the Perryridge branch.
Solution:
 customer_name (branch_name=“Perryridge”
(borrower.loan_number = loan.loan_number(borrower x loan)))

 customer_name(loan.loan_number = borrower.loan_number (
(branch_name = “Perryridge” (loan)) x borrower))

 select customer_name, borrower.loan_number, amount from borrower, loan


where borrower.loan_number = loan.loan_number and
branch_name = 'Perryridge'

You might also like