Fall08_RelAlg

Fall08_RelAlg - RELATIONAL ALGEBRA (Chapter 2) 1 01/11/09...

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

View Full Document Right Arrow Icon
01/11/09 1 RELATIONAL ALGEBRA (Chapter 2)
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
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. <
Background image of page 4
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#
Background image of page 5

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

View Full DocumentRight Arrow Icon
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#
Background image of page 6
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#
Background image of page 7

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

View Full DocumentRight Arrow Icon
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#
Background image of page 8
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#
Background image of page 9

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

View Full DocumentRight Arrow Icon
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))
Background image of page 10
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#
Background image of page 11

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

View Full DocumentRight Arrow Icon
01/11/09 12 EXAMPLE
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 45

Fall08_RelAlg - RELATIONAL ALGEBRA (Chapter 2) 1 01/11/09...

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

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