cs411-04-relalgebra-new

# cs411-04-relalgebra-new - 1 CS411 Database Systems 04:...

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

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document

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.

Unformatted text preview: 1 CS411 Database Systems 04: Relational Algebra 2 Why Do We Learn This? 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 . 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 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()); 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 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 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. 9 Q: Example algebra? Arithmetic algebra. Linear algebra. What are operands? What are operators? 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. 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: s Projection: p Cartesian Product: X When our relations have attribute names: Renaming: r Derived operations: Intersection, complement Joins (natural,equi-join, theta join, semi-join) 12 Basic RA Operations...
View Full Document

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

### Page1 / 53

cs411-04-relalgebra-new - 1 CS411 Database Systems 04:...

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

View Full Document
Ask a homework question - tutors are online