Chapter 4 Relational Algebra Relational Languages Relational Algebra
Chapter 4 Relational Algebra • Relational Languages • Relational Algebra
Relational Languages • Procedural language – Relational algebra • Non-procedural language – Relational Calculus (pp. 101 - 107)
Relational Algebra Intra Relation Selection - horizontal partition – SELECT relation WHERE condition [GIVING relation] � condition(relation) Projection - vertical partition – PROJECT relation OVER (attribute, . . . )[GIVING relation] � attributes(relation)
Union-Compatible Union - tuples in either of 2 union compatible relations – relation 1 UNION relation 2 [GIVING relation] – relation 1 relation 2 Difference - tuples in one union compatible relation, but not other —relation 1 MINUS relation 2 [GIVING relation] —relation 1 - relation 2
Union-Compatible Intersection - tuples in both of 2 union compatible relations – relation 1 INTERSECT relation 2 [GIVING relation] – relation 1 relation 2
Any 2 Relations Product - Cartesian product of any two relations – relation 1 TIMES relation 2 [GIVING relation] – relation 1 relation 2 Join - common domain – relation 1 JOIN relation 2 WHERE condition [GIVING relation] – relation 1 condition relation 2 • Division – relation 1 divided by relation 2 [GIVING relation] – relation 1 / relation 2
Types of Join Equi : based on equality with 2 identical attribute columns Theta : a join based on a relational operator (=, <, >, <=, >=, ~=) Natural : equijoin with no duplicate column Outer : includes tuples without matches (left, right, full)
Types of Join • Semi-join – relation 1 SEMIJOIN relation 2 WHERE condition [GIVING relation] – relation 1 lxcondition relation 2 • Semi-theta-join • Semi-natural join
Assignment • • Review chapters 1 -4 Read Chapters 6 -5 Do Exercise 4. 12 Due date:
- Slides: 9