Chapter32

# Chapter32 - CSIS0278A CSIS0278A ManagementSystems Lecture 3...

This preview shows pages 1–12. Sign up to view the full content.

CSIS0278A CSIS0278A Introduction to Database  Introduction to Database  Management Systems Management Systems Lecture 3: Relational Model Part 2 Dr. Reynold Cheng Based on the Ch. 2 notes of “Database System Concepts” by A. Silberschatz, H. Korth & S. Sudarshan and notes by Dr. HO Wai Shing

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
DB035:2 Overview Overview Additional relational algebra operations Intersection, Join, Division, Assignment Extended relational algebra operations Generalized Projection, Outer join, Aggregate Modification of databases Deletion, Insertion, Updating
DB035:3 Additional Operations Additional Operations Set intersection Natural join Division Assignment They do not add any power to relational algebra, but simplify common queries .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
DB035:4 Set Intersection Operation –  Set Intersection Operation –  Example  Example  R S Relation R, S A B 1 2 A B 1 2 2 2 A B 1 1 2 1 2 3 R S
DB035:5 Set Intersection Operation Set Intersection Operation Notation: R S Definition: R S = { t | t R t S } For R S to be valid , R and S must have the same arity , and The attribute domains must be compatible . e.g., Find out all customers who have both an account and a loan π customer_name (Depositor) π customer_name (Borrower) Note that R S = R – (R – S)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
DB035:6 Natural Join Operation –  Natural Join Operation –  Example  Example  R S Relation R, S A C 1 2 2 2 A B 1 1 2 1 2 3 R S A B C 1 1 2 1 2 3 2 2 2
DB035:7 Natural Join Operation Natural Join Operation Combines information from multiple tables e.g., Natural joining Depositor and Customer creates tuples that contain both account and customer info One of the most commonly used operator!

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
DB035:8 Natural Join Operation Natural Join Operation Notation: R S Definition: The schema of R S is R-schema S schema (note: repeated attributes are removed) For each pair of tuples t r from R and t s from S, if t r and t s share the same value over each of the common attributes in R and S, one tuple t will be added to the result of R S. t has the same value as t r in R’s attributes, and t has the same value as t s in S’s attributes. e.g., R(A, B, C, D), S(C, D, E) Schema of R S = (A, B, C, D, E) R S is defined as: π R.A, R.B, R.C, R.D, S.E ( σ R.C = S.C R.D = S.D (R × S))
DB035:9 Division Operation – Example  Division Operation – Example  Relation R B 1 2 S A B 1 1 2 1 2 2 3 4 4 1 4 4 5 1 5 2 5 3 Q=R ÷ S A 2 5 Q × S R A B 2 1 2 2 5 1 5 2 Largest relation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Division Operation – Example  Division Operation – Example  1 (cont.)  1 (cont.)  Relation R B 1 2 S A B 1 1 2 1 2 2 3 4 4 1 4 4 5 1 5 2 5 3 Q 0 A B 2 1 2 2 5 1 5 2 3 1 3 2 A 2 5 3
DB035:11 Division Operation – Example  Division Operation – Example  1 (cont.)  1 (cont.)  Relation R B 1 2 S A B 1 1 2 1 2 2 3 4 4 1 4 4 5 1 5 2 5 3 Q 1 A 2 A=5 is not included in Q 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/01/2010 for the course CS 0278 taught by Professor Dr during the Spring '10 term at HKU.

### Page1 / 42

Chapter32 - CSIS0278A CSIS0278A ManagementSystems Lecture 3...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online