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 13. Extension and Summarization Views

Flimmery flummery

Extension and summary

Both follow the rules

Taught in all the best schools

Anon.:

The relational EXTEND and SUMMARIZE operators resemble each other inasmuch as they both produce a result containing a new “computed” attribute.[128] Informally, we might say that EXTEND performs computation “across tuples,” while SUMMARIZE performs computation “down attributes.” However, I hasten to add that this characterization is loose in the extreme, as is shown by—among other things—the fact that SUMMARIZE can actually be defined in terms of EXTEND, as is explained in SQL and Relational Theory (and as indeed was noted in passing in the previous chapter).

An Extend Example

I’ll begin with a simplified version of an example from Chapter 2. First, let’s agree for simplicity to ignore all attributes of relvar P other than PNO and WEIGHT. Second, suppose WEIGHT values in that relvar are given in pounds. Third, suppose we want to see those weights in grams. There are 454 grams to a pound, and so we can write:

EXTEND P : { GMWT := WEIGHT * 454 }

Given our usual sample values, the result looks like this:

+-----------------------+
| PNO | WEIGHT | GMWT   |
+-----+--------+--------|
| P1  |   12.0 | 5448.0 |
| P2  |   17.0 | 7718.0 |
| P3  |   17.0 | 7718.0 |
| P4  |   14.0 | 6356.0 |
| P5  |   12.0 | 5448.0 |
| P6  |   19.0 | 8626.0 |
+-----------------------+

So let’s assume relvar P is a base relvar (as usual), and let’s define an extended version as above—let’s call ...

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