Database Systems: SQL and Aggregate Functions, Study Guides, Projects, Research of Introduction to Database Management Systems

Announcements for a database systems course, including reading assignments, homework assignments, and exam information. Topics covered include sql, join variations, division operator, and aggregate functions. Students are expected to complete exercises and should not cheat on programs.

Typology: Study Guides, Projects, Research

2011/2012

Uploaded on 02/15/2012

arien
arien 🇺🇸

4.8

(24)

309 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Announcements
Reading assignment Chapter 8 – SQL
Written Homework 1 will be officially assigned on
Tuesday, due Nov 2
Exercises 5.12, 5.15, 6.17, 6.20, 6.22 (a,c,f only).
Programs: please don’t cheat
Today
Exam recap and solution
Wrap up chapter 6
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Database Systems: SQL and Aggregate Functions and more Study Guides, Projects, Research Introduction to Database Management Systems in PDF only on Docsity!

Announcements

•^

Reading assignment Chapter 8 – SQL

-^

Written Homework 1 will be officially assigned onTuesday, due Nov 2–

Exercises 5.12, 5.15, 6.17, 6.20, 6.22 (a,c,f only).

•^

Programs: please don’t cheat

-^

Today– Exam recap and solution– Wrap up chapter 6

DIVISION operator (less common)

•^

DIVISION useful for queries such as:– “Retrieve the names of employees who work on all

the projects that ‘John Smith’ works on“

  • T(Y) = R(Z)

÷

S(X), X must be a subset of Z

  • Attributes of result set (Y) are attrs of R not in S
    • Y = Z – X
      • Result is a relation T(Y) that includes a tuple t if

tuples t

R^

appear in R with t

R^

[Y] = t, and

with t

R^

[X] = t

s^

for every tuple

ts

in S.

  • See example

Attributes of R

Attributes of S

Example of DIVISION

Aggregate Function Operation

-^

Use of the Aggregate Functional operation

-^

MAX Salary

(EMPLOYEE) retrieves the maximum salary value

from the EMPLOYEE relation

-^

MIN Salary

(EMPLOYEE) retrieves the minimum Salary value from

the EMPLOYEE relation

-^

SUM Salary

(EMPLOYEE) retrieves the sum of the Salary from the

EMPLOYEE relation

-^

COUNT SSN, AVERAGE Salary

(EMPLOYEE) computes the count

(number) of employees and their average salary• Note: count just counts the number of rows, without removing

duplicates

Grouping with Aggregate Functions

• F

( R, , )

• F

(EMPLOYEE, {}, MAX Salary)

• F

(EMPLOYEE, Dno, Avg Salary) A relation

Set of attributes in RTo group by beforeapplying theaggregate function

set of (aggr. function, attribute)

Max salary in whole comp.Get avg salary for eachdeparment

Additional Relational Operations (cont.)

-^

The OUTER JOIN Operation– In NATURAL JOIN and EQUIJOIN, tuples without a

matching

(or

related

) tuple are eliminated from the join result

  • Tuples with null in the join attributes are also eliminated• This amounts to loss of information.
    • A set of operations, called OUTER joins, can be used when we

want to keep all the tuples in R, or all those in S, or all those inboth relations in the result of the join, regardless of whether ornot they have matching tuples in the other relation.

Additional Relational Operations (cont.)

•^

The left outer join operation keeps every tuple inthe first or left relation R in R

S; if no

matching tuple is found in S, then the attributesof S in the join result are filled or “padded” withnull values.

-^

A similar operation, right outer join, keeps everytuple in the second or right relation S in theresult of R

S.

•^

A third operation, full outer join, denoted bykeeps all tuples in both the left and the rightrelations when no matching tuples are found,padding them with null values as needed.