Fall08_RelAlg

# Fall08_RelAlg - RELATIONAL ALGEBRA(Chapter 2 1 Overall...

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

01/11/09 1 RELATIONAL ALGEBRA (Chapter 2)

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

View Full Document
01/11/09 2 Overall Organization File System Buffer Pool Manager Abstraction of records Index structures Query Interpretor Query Optimizer Relational Algebra operators: , σ , ρ , δ , , , , ÷ , - Query Parser
01/11/09 3 RELATIONAL ALGEBRA INTRODUCTION Assume the following two relations: Emp (SS#, name, age, salary, dno) Dept (dno, dname, floor, mgrSS#) Relational algebra is a procedural query language, i.e., user must define both “how” and “what” to retrieve. Relational algebra consists of a set of operators that consume either one or two relations as input. An operator produces one relation as its output. Unary operators include: select, project, and rename Binary operators include: cartesian product, equality join, natural join, join, semi-join, division, union, and set difference.

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

View Full Document
01/11/09 4 SELECT OPERATOR Select ( б ): selects tuples that satisfy a predicate; e.g., retrieve the employees whose salary is 30,000 б Salary=30,000 (Employee) Conjunctive ( ) and disjunctive ( ) selection predicates are allowed; e.g., retrieve employees whose salary is higher than 30,000 and are younger than 25 years old: б Salary>30,000 age<25 (Employee) Note that only selection predicates are allowed. A selection predicate is either (1) a comparison (=, ≠, ≤, ≥, <, >) between an attribute and a constant (e.g., salary = 30,000) or (2) a comparison between two different attributes of the same relation (e.g., salary = age × 100). Note: This operator is different than the SELECT command of SQL. <
01/11/09 5 EXAMPLE Emp table: 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS#

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

View Full Document
01/11/09 6 EXAMPLE Emp table: б Salary=30,000 (Employee) 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS#
01/11/09 7 EXAMPLE Emp table: б Salary=30,000 (Employee) 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS# 5 30000 30 Kathy 4 dno Salary Age Name SS#

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

View Full Document
01/11/09 8 EXAMPLE Emp table: б Age>22 (Employee) 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS#
01/11/09 9 EXAMPLE Emp table: б Age>22 (Employee) 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS# 5 30000 30 Kathy 4 2 20000 24 Joe 1 dno Salary Age Name SS#

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

View Full Document
01/11/09 10 PROJECT OPERATOR Project ( ) retrieves a column. It is a unary operator that eliminate duplicates. e.g., name of employees: name (Employee) e.g., name of employees earning more than 30,000: name ( б Salary>30,000 (Employee))
01/11/09 11 EXAMPLE Emp table: 1 4000 4 Shideh 5 5 30000 30 Kathy 4 4 27000 22 Bob 3 3 25000 20 Mary 2 2 20000 24 Joe 1 dno Salary Age Name SS#

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

View Full Document
01/11/09 12 EXAMPLE
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/11/2009 for the course CSCI 485 taught by Professor Ghandeharizadeh during the Fall '08 term at USC.

### Page1 / 45

Fall08_RelAlg - RELATIONAL ALGEBRA(Chapter 2 1 Overall...

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

View Full Document
Ask a homework question - tutors are online