From Clause & Tuples

  • Uploaded by: Ayisha
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View From Clause & Tuples as PDF for free.

More details

  • Words: 301
  • Pages: 8
The from Clause • The from clause lists the relations involved in the query – corresponds to the Cartesian product operation of the relational algebra.

• Find the Cartesian product employee x department select  from employee, department ■   Find the  employee name, deptno and deptname of all employees select name, employee.eno, deptname  from employee, dept  where  employee. eno = dept.eno

Figure 3.3: Tuples inserted into

Figure 3.4:

Tuple Variables

• Tuple variables are defined in the from clause via the use of the as clause. • Find the customer names and their loan numbers for all customers having a loan at some branch.

select customer­name, T.loan­number, S.amount           from borrower as T, loan as S           where T.loan­number = S.loan­number ■    Find the names of all branches that have greater assets than        some branch located in Brooklyn. select distinct T.branch­name     from branch as T, branch as S     where T.assets > S.assets and S.branch­city = ‘Brooklyn’

Set Operations

• Find all customers who have a loan, an account, or both: (select customer­name from depositor) union (select customer­name from borrower) ■    Find all customers who have both a loan and an  (select customer­name from depositor) intersect (select customer­name from borrower) ■   Find all customers who have an account but no loan. (select customer­name from depositor) except (select customer­name from borrower)



Ordering the Display of List in alphabeticTuples order the names of all customers having a loan in Perryridge branch

select distinct customer-name from borrower, loan where borrower loan-number = loan.loan-number and branch-name = ‘Perryridge’ order by customer-name • We may specify desc for descending order or asc for ascending order, for each attribute; ascending order is the default. – E.g. order by customer-name desc

Example 2 • Sailors (sid,sname, rating,age) • Boats(bid, bname,color) • Reserves(sid,bid ,date) • Refer to attached list for rows

Related Documents

From Clause & Tuples
May 2020 10
Defining Clause
November 2019 29
If-clause
October 2019 28
Independent Clause
June 2020 11
Adjective Clause
June 2020 13
Structure_that Clause
July 2020 7

More Documents from ""

Queries
May 2020 14
From Clause & Tuples
May 2020 10
Constraints
May 2020 16
Summary Of Db
May 2020 11
E-r Model
May 2020 11
Dbms Into
May 2020 27