Relational_Algebra

# Relational_Algebra - Introduction to Relational Algebra...

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

Introduction to Relational Algebra

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

View Full Document
Overview b Introduction b Unary Relational Operations s SELECT, PROJECT, Rename b Relational Algebra Operations from Set Theory b Binary Relational Operations b Additional Relational Operations b Examples of Queries in Relational Algebra
Relational Algebra

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

View Full Document
Relational Algebra b The basic set of operations for the relational model is known as the relational algebra . s enable a user to specify basic retrieval requests. b The result of a retrieval is a new relation , which may have been formed from one or more relations. b The algebra operations thus produce new relations, which can be further manipulated using operations of the same algebra. b A sequence of relational algebra operations forms a relational algebra expression , whose result will also be a relation that represents the result of a database query (or retrieval request)
Unary Relational Operations b SELECT (symbol: σ (sigma)) b PROJECT (symbol: Π (pi)) b RENAME (symbol: ρ (rho))

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

View Full Document
Unary Relational Operations - SELECT b Let relation r have attributes X,Y,. .,Z , and let p be a truth-valued function whose parameters are, some subset of X,Y,. .,Z . Then the restriction of s r according to p s r WHERE p b – is a relation with the same heading as r and with body consisting of all tuples of r such that p evaluates to TRUE for the tuple in question. b The expression p is a predicate
Unary Relational Operations - SELECT b SELECT operation is used to select a subset of the tuples from a relation that satisfy a selection condition . b It is a filter that keeps only those tuples that satisfy a qualifying condition – those satisfying the condition are selected while others are discarded. b The select operation is denoted by: s σ <selection condition>(R) s where the symbol σ (sigma) – denote the select operator s <selection condition> - Boolean expression specified on the attributes of relation R

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

View Full Document
Unary Relational Operations - SELECT b The boolean expression specified in <selection condition> is made up of: s <attribute name> <comparion op> <constant value>, or s <attribute name> <comparion op> <attribute name> s where < attribute name > - any attribute of R s < comparion op > - { =, <, <=, >, >=, != } b Clauses can be connected by Boolean operators AND, OR, and NOT: b σ DNO = 4 AND SALARY>2500 (EMPLOYEE)
Unary Relational Operations - SELECT b Example: To select the EMPLOYEE tuples whose department number is four or those whose salary is greater than \$30,000 the following notation is used: b σ DNO = 4 OR SALARY > 30,000 (EMPLOYEE) s The SELECT operator is unary – applied to a single relation s The degree of the relation resulting from SELECT is the same as that of R s The number of tuples in the resulting relation is always less or equal to the number of tuples in R

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

View Full Document
Unary Relational Operations – PROJECT b Selects certain
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 39

Relational_Algebra - Introduction to Relational Algebra...

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

View Full Document
Ask a homework question - tutors are online