Chapter32

Chapter32 - CSIS0278A CSIS0278A IntroductiontoDatabase...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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 .
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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)
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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!
Background image of page 7

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

View Full DocumentRight Arrow Icon
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))
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 42

Chapter32 - CSIS0278A CSIS0278A IntroductiontoDatabase...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online