Updating groups

Don’t need no loops—

I turn now to the question of updating through the relational grouping and ungrouping operators (GROUP and UNGROUP, in **Tutorial D**). Since you might not be familiar with those operators, I’ll begin with a brief tutorial.

Consider the relations shown in Figure 12-1, which we can take to be the current values of two relvars called SP and SPQ, respectively. Of course, relvar SP is just the shipments relvar from our usual suppliers-and-parts database.

Figure 12-1. Relvars SP and SPQ—sample values

Now, I hope it’s at least intuitively obvious that we have information equivalence here once again^{[119]} (certainly the relations shown in the figure both represent the exact same information).

Now, with regard to those two relations, the one on the left of the figure is just a reduced version of our usual sample value for relvar SP, while the one on the right is what we get if we evaluate the following expression on that sample SP value:

SP GROUP ( { PNO , QTY } AS PQ )

Aside: In fact the GROUP invocation just shown is logically equivalent to a certain EXTEND invocation—to be specific, the invocation EXTEND SP{SNO}:{PQ := s!!SP}, where !!SP denotes a certainimage relation^{[120]}—and there are reasons to prefer this EXTEND formulation over its GROUP equivalent. Detailed discussion of such matters ...

Start Free Trial

No credit card required