Download presentation

Presentation is loading. Please wait.

Published byAdrien Easterbrook Modified about 1 year ago

1
Relational Algebra Jermaine Rodney

2
What is an “Algebra” Mathematical system consisting of: Operands --- Variables or values from which new values can be constructed. Operators --- Symbols denoting procedures that construct new values from given values.

3
What is Relational Algebra? An Operators are mathematical functions used to retrieve queries by describing a sequence operations on tables or even databases(schema) involved.

4
Relational algebra received little attention outside of pure mathematics until the publication of E.F. Codd's relational model of data in 1970. Codd proposed algebra as a basis for database query languages.

5
Core Relational Algebra The relational algebra uses set union, set difference, and Cartesian product from set theory, but adds additional constraints to these operators.

6
Constraints For set union and set difference, the two relations involved must be union- compatible—that is, the two relations must have the same set of attributes. Because set intersection can be defined in terms of set difference, the two relations involved in set intersection must also be union-compatible.

7
Constraints cont. For the Cartesian product to be defined, the two relations involved must have disjoint headers—that is, they must not have a common attribute name.

8
Core Relational Algebra Selection: picking certain rows. Projection: picking certain columns. Joins: compositions of relations. Renaming of relations and attributes etc.

9
Operations Projection (π) Selection (σ) Rename (ρ) Natural join ( ⋈ ) Division (÷) Cartesian product (×) Set intersection (∩) Set union ( ∪ )

10
Selection Operation PROF ID#NAMEDEPTRANKSAL. 1AdamCSASST6000 2BobEEASSO8000 3CalvinCSFULL10000 4DorothyEEASST5000 5EmilyEEASSO8500 6FrankCSFULL9000 σSAL. >= 8500(PROF) ∩ σDEPT = CS(PROF) Selection (σ)

11
σSAL. >= 8500(PROF) ∩ σdept = CS(PROF) returns: ID#NAMEDEPTRANKSAL. 3CalvinCSFULL10000 6FrankCSFULL9000

12
Natural Join 1 Denoted by T 1 ⋈ T 2 Where T 1 andT 2 are tables. The output of the operation is a table T such that: The schema of T includes all the distinct columns of T 1 andT 2.

13
TEACH ID#CIDYEAR 1C12011 2C22012 1C22012

14
PROF ⋈ TEACH Returns: ID#NAMEDEPTRANKSAL.CIDYEAR 1AdamCSASST6000C12011 2BobEEASSO8000C22012 1AdamCSASST6000C22012 Natural join ( ⋈ )

15
Renaming The ρ operator gives a new schema to a relation. R1 := ρ R1(A1,...,An) (R2) makes R1 be a relation with attributes A1,...,An and the same tuples as R2. Simplified notation: R1(A1,...,An):= R2.

16
Example: Renaming Bars( ) R(bar, addr):=Bars R ( ) baraddr Joe’sMaple St. Sue’sRiver RD.

17
Work Cited http://www.cse.cuhk.edu.hk/~taoyf/cours e/bmeg3120/notes/rel-algebra2.pdf http://www.cse.cuhk.edu.hk/~taoyf/cours e/bmeg3120/notes/rel-algebra2.pdf http://en.wikipedia.org/wiki/Relational_al gebra http://en.wikipedia.org/wiki/Relational_al gebra http://www.youtube.com/watch?v=3Xu_L WK3SWw

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google