O'Reilly logo

View Updating and Relational Theory by Chris Date

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Group and Ungroup Views

Updating groups

Don’t need no loops

Anon.:

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.

The Group and Ungroup Operators

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.

Relvars SP and SPQ—sample values
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 certain image relation[120]—and there are reasons to prefer this EXTEND formulation over its GROUP equivalent. Detailed discussion of such matters ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required