23-RelationalAlgebra

23-RelationalAlgebra - Discussion #23 Relational Algebra...

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

View Full Document Right Arrow Icon
Discussion #23 1/32 Discussion #23 Relational Algebra
Background image of page 1

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

View Full DocumentRight Arrow Icon
Discussion #23 2/32 Topics Algebras Relational Algebra use of standard notation set operators , , - renaming ρ selection σ projection π cross product × join | × | Queries (from English) Query optimization SQL
Background image of page 2
Discussion #23 3/32 Relational Algebra What is an algebra? a pair: (set of values, set of operations) ADT type Class Object e.g. stack: (set of all stacks, {pop, push, top, …}) integer: (set of all integers, {+, -, *, ÷ }) What is relational algebra? (set of relations, set of relational operators) { , , - , ρ , σ , π , × , | × |} Notation: We’ll use standard notation. Names: same as book’s (except selection = restriction) Definitions the same, syntax different
Background image of page 3

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

View Full DocumentRight Arrow Icon
Discussion #23 4/32 Relational Algebra is Closed Closed: all operations produce values in the value set (reals, {+, *, - }) closed (reals, {+, *, - , ÷ }) not closed (divide by 0) (reals, {+, *, >}) not closed (T/F not in value set) (computer reals, {+, *, - }) not closed (overflow, roundoff) (relations, relational operators) closed Implication: we can always nest relational operators; can’t for algebras that are not closed. e.g. after overflow, can do nothing e.g. can’t always nest: (2 < 3) + 5 = ?
Background image of page 4
Discussion #23 5/32 Set Operations: , , and - Relations are sets; thus set operations should work. Examples: R = A B 1 2 2 2 2 3 S = A B 2 2 2 3 4 2 5 5 R S = A B 1 2 2 2 2 3 4 2 5 5 R S = A B 2 2 2 3 R - S = A B 1 2 S - R = A B 4 2 5 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Discussion #23 6/32 Set Operations (continued …) Definition: schema(R) = {A, B} = AB, i.e. the set of attributes We sometimes write R(AB) to mean the relation R with schema AB. Definition: union compatible schema(R) = schema(S) required precondition for , , - Definitions: R S = { t | t R t S} R S = { t | t R t S} R - S = { t | t R t S}
Background image of page 6
7/32 Tuple Restriction: [X] Restriction is a tuple operator (not a relational operator). t[X] restricts tuple t to the attributes in X. A
Background image of page 7

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

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

This note was uploaded on 03/02/2012 for the course C S 236 taught by Professor Michaelgoodrich during the Winter '12 term at BYU.

Page1 / 32

23-RelationalAlgebra - Discussion #23 Relational Algebra...

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

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