09-04-2014, 04:36 PM
Additional Relational Algebra
Additional Relational.ppt (Size: 381.5 KB / Downloads: 16)
Additional Operations
Additional Operations
Set intersection
Natural join
Aggregation
Outer Join
Division
All above, other than aggregation, can be expressed using basic operations we have seen earlier
Natural-Join Operation
Let r and s be relations on schemas R and S respectively.
Then, r s is a relation on schema R S obtained as follows:
Consider each pair of tuples tr from r and ts from s.
If tr and ts have the same value on each of the attributes in R S, add a tuple t to the result, where
t has the same value as tr on r
t has the same value as ts on s
Example:
R = (A, B, C, D)
S = (E, B, D)
Result schema = (A, B, C, D, E)
r s is defined as:
r.A, r.B, r.C, r.D, s.E (r.B = s.B r.D = s.D (r x s))
Outer Join
An extension of the join operation that avoids loss of information.
Computes the join and then adds tuples form one relation that does not match tuples in the other relation to the result of the join.
Uses null values:
null signifies that the value is unknown or does not exist
All comparisons involving null are (roughly speaking) false by definition.
Generalized Projection
Extends the projection operation by allowing arithmetic functions to be used in the projection list.
E is any relational-algebra expression
Each of F1, F2, …, Fn are are arithmetic expressions involving constants and attributes in the schema of E.
Given relation credit_info(customer_name, limit, credit_balance), find how much more each person can spend:
customer_name, limit – credit_balance (credit_info)