Tuples

Set Operations on Relations

The three most common operations on sets are union, intersection, and difference. We assume the reader is familiar with these operations, which are described as follows on arbitrary sets R and S:

Selection / Cartesian Product

The selection operator, applied to a relation R, creates a new relation with a subset of R's tuples. The tuples in the resulting relation are those that satisfy some condition C that involves the attributes of R. We denote this operation σc(R). The schema for the resulting relation is the

Dependent and Independent Operations

Some of the operations that we have explained in previous sections can be expressed in terms of other relational-algebra operations. For instance, intersection can be expressed in terms of set difference:

Relational Operations on Bags

While a set of tuples (i.e., a relation) is a simple, natural model of data as it might appear in a database, commercial database systems rarely, if ever, are based entirely on sets. In some situations, relations as they appear in database systems are allowed to have duplicate

Union, Intersection, and Difference of Bags

When we take the union of two bags, we add the number of occurrences of each tuple. That is, if R is a bag in which the tuple t appears n times, and S is a bag in which the tuple t appears m times, then in the bag R U S tuple t appears n + m times. Note that either n or m (or

Selection on Bags / Product of Bags / Joins of Bags

To apply a selection to a bag, we apply the selection condition to each tuple separately. As always with bags, we do not remove duplicate tuples in the result.

Extended Operators of Relational Algebra

An Algebra of Relational Operations presented the classical relational algebra, and Relational Operations on Bags introduced the modifications required to treat relations as bags of tuples rather than sets. The ideas of these two sections serve as a base for most of

Grouping

Sometimes we do not want simply the average or some other aggregation of an entire column. Rather, we need to examine the tuples of a relation in groups, equivalent to the value of one or more other columns, and we aggregate only within each group. As an example, assume

Extending the Projection Operator

Well now reexamine the projection operator πL(R) introduced in Set Operations on Relations under projection. In the classical relational algebra, L is a list of (some of the) attributes of R. We extend the projection operator to allow it to compute with components of tuples as well

Additional Constraint Examples

The same constraint notation permits us to express far more than referential integrity. For instance, we can express any functional dependency as an algebraic constraint, although the notation is more awkward than the FD notation introduced in Functional Dependencies.

Page 4 of 7 Previous 1 2 3 4 5 6 7 Next