Fundamentals/ICY: Databases 2012/13 WEEK 11 (relational operators & relational algebra). John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK. Relational algebra
Professor of Artificial Intelligence
School of Computer Science
University of Birmingham, UK
Defines theoretical way of manipulating tables using “relational operators” that mainly manipulate the relations in the tables.
JOIN (various sorts)
Use of relational algebra operators on existing tables produces new tables
((DIVIDE))Relational Database Operators
Union of relations R and S:
R S = the set of tuples that are in R or S (or both).
NB: no repetitions created!
Intersection of relations R and S:
R S = the set of tuples that are in both R and S.
Difference of relations R and S:
R S = the set of tuples that are in R but not S.
Those operations do NOT themselves require R and S to have similar tuples in order to be well-defined.
E.g., R could be binary and on integer sets, S could be ternary and on character-string sets.
But the corresponding DB table operations (which are usually called “relational operators”) do require the tables to have the same shape (same number of columns, same domains for corresponding columns).
If second table also had a PRICE attribute, then the product would have a Table1.PRICE attr. and a Table2.PRICE attr.
Note the two AGENT_CODE columns
Same as an equijoin with the addition of the “extra”, last, row shown above
Full Outer Join:
Would have the “extra” row of this table as well as the extra row of the Left Outer Join table
Simplest case: 2-col table by 1-col table
The only value of LOC that is associated in T with both values ‘A’ and ‘B’ of CODE is 5.