















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















































COP 4710: Database Systems (Chapter 5)
Page 1
School of Electrical Engineering and Computer Science
University of Central Florida
Instructor :
Dr. Mark [email protected] 236, 407-823-
http://www.cs.ucf.edu/courses/ccop4710/fall
COP 4710: Database Systems (Chapter 5)
Page 2
Mark Llewellyn
a relational operation that causes two or more tables with a
common domain to be combined into a single table or view
a join in which the joining condition is based on equality
between
values
in
the
common
columns;
common
columns
appear
redundantly in the result table
an equi-join in which one of the duplicate columns is
eliminated in the result table
a join in which rows that do not have matching values in
common columns are nonetheless included in the result table (as opposedto
inner
join, in which rows must have matching values in order to appear
in the result table)
instance for each row of each table The common columns in joined tables are usually the primary key of thedominant table and the foreign key of the dependent table in 1:M relationships
COP 4710: Database Systems (Chapter 5)
Page 4
COP 4710: Database Systems (Chapter 5)
Page 5
Join involves multiple tables in FROM clause
WHERE clause performs theequality check for commoncolumns of the two tables
COP 4710: Database Systems (Chapter 5)
Page 7
LEFT OUTER JOIN syntax withON keyword instead of WHERE Æ
causes customer data to appear even if there is no correspondingorder data
COP 4710: Database Systems (Chapter 5)
Page 8
Outer join in Oracle uses regular joinsyntax, but adds (+) symbol to theside that will have the missing data
COP 4710: Database Systems (Chapter 5)
Page 10
COP 4710: Database Systems (Chapter 5)
Page 11
Mark Llewellyn
-^
-^
-^
COP 4710: Database Systems (Chapter 5)
Page 13
COP 4710: Database Systems (Chapter 5)
Page 14
The subqueryexecutes andreturns thecustomer IDs fromthe ORDER_T table
The outer query onthe results of thesubquery
COP 4710: Database Systems (Chapter 5)
Page 16
Subquery refers to outer-query data, so executes oncefor each row of outer query
Note: only theorders thatinvolveproducts withNatural Ash willbe included inthe final results
COP 4710: Database Systems (Chapter 5)
Page 17
(SELECT AVG(STANDARD_PRICE) AVGPRICE FROM PRODUCT_T),PRODUCT_TWHERE STANDARD_PRICE > AVG_PRICE;
The WHERE clause normally cannot include aggregate functions, but because the aggregate isperformed in the subquery its result can be used in the outer query’s WHERE clause
One column of the subquery is anaggregate function that has an aliasname. That alias can then be referredto in the outer query
Subquery forms the derived table usedin the FROM clause of the outer query
COP 4710: Database Systems (Chapter 5)
Page 19
-^
-^
-^
-^
SELECT P_CODE, P_DESCRIPT, P_PRICE, V_NAME
FROM PRODUCT, VENDORWHERE PRODUCT.V_CODE = VENDOR.V_CODE;
COP 4710: Database Systems (Chapter 5)
Page 20
Mark Llewellyn
SELECT
column-list
FROM
table1, table
;
SELECT
column-list
FROM
table1 CROSS JOIN table
;
old style syntaxnew style syntax