cs411-04-relalgebra - CS411 Database Systems 04: Relational...

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

View Full Document Right Arrow Icon
1 CS411 Database Systems 04: 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
2 Why Do We Learn This?
Background image of page 2
3 Querying the Database • Goal: specify what we want from our database Find all the employees who earn more than $50,000 and pay taxes in Champaign-Urbana. • Could write in C++/Java, but bad idea • Instead use high-level query languages: – Theoretical: Relational Algebra, Datalog – Practical: SQL – Relational algebra: a basic set of operations on relations that provide the basic principles .
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Motivation: The Stack • To use the "stack" data structure in my program, I need to know – what a stack looks like – what (useful) operations I can perform on a stack • PUSH and POP • Next, I look for an implementation of stack – browse the Web – find many of them – choose one, say LEDA
Background image of page 4
5 Motivation: The Stack (cont.) • LEDA already implement PUSH and POP • It also gives me a simple language L, in which to define a stack and call PUSH and POP – S = init_stack(int); – S.push(3); S.push(5); – int x = S.pop(); • Can also define an expression of operations on stacks – T = init_stack(int); – T.push(S.pop());
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Motivation: The Stack (cont.) • To summarize, I know – definition of stack – its operations (PUSH, POP): that is, a stack algebra –an implementation called LEDA, which tells me how to call PUSH and POP in a language L – I can use these implementations to manipulate stacks – LEDA hides the implementation details – LEDA optimizes implementation of PUSH and POP
Background image of page 6
7 Now Contrast It with Rel. Databases • To summarize, I know – definition of stack – its operations (PUSH, POP): that is, a stack algebra –an implementation called LEDA, which tells me how to call PUSH and POP in a language L – I can use these implementations to manipulate stacks – LEDA hides the implementation details – LEDA optimizes implementation of PUSH and POP def of relations relational algebra SQL language operation and query optimization
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 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.
Background image of page 8
9 Q: Example algebra? • Arithmetic algebra. Linear algebra. • What are operands? • What are operators?
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 What is Relational Algebra? • An algebra whose operands are relations or variables that represent relations. • Operators are designed to do common things that we need to do with relations in a database. • The result is an algebra that can be used as a query language for relations.
Background image of page 10
11 Relational Algebra at a Glance • Operators: relations as input, new relation as output • Five basic RA operations: – Basic Set Operations • union, difference (no intersection, no complement) – Selection: – Projection: – Cartesian Product: X • When our relations have attribute names: – Renaming: • Derived operations: – Intersection, complement – Joins (natural,equi-join, theta join, semi-join)
Background image of page 11

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

View Full DocumentRight Arrow Icon
12 Basic RA Operations
Background image of page 12
13 Set Operations • Union, difference • Binary operations
Background image of page 13

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

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

This note was uploaded on 02/17/2012 for the course CS 411 taught by Professor Winslett during the Spring '07 term at University of Illinois at Urbana–Champaign.

Page1 / 53

cs411-04-relalgebra - CS411 Database Systems 04: Relational...

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

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