Databases Reference
In-Depth Information
ON INSERT i INTO PL′ : INSERT i INTO POI ;
ON INSERT i INTO PK′ : INSERT i INTO POI ;
ON DELETE d FROM PL′ : DELETE d FROM POI ;
ON DELETE d FROM PK′ : DELETE d FROM POI ;
And here are the rules involving relvars PL′ and PK′ and relvar DLK′:
ON INSERT i INTO PL′ : INSERT ( i WHERE NOT ( IN_STOCK ) ) INTO DLK′ ;
ON INSERT i INTO PK′ : DELETE i FROM DLK′ ;
ON DELETE d FROM PL′ : DELETE d FROM DLK′ ;
ON DELETE d FROM PK′ : INSERT ( d WHERE ON_SALE ) INTO DLK′ ;
ON INSERT i INTO DLK′ : INSERT i INTO PL′ ;
ON DELETE d FROM DLK′ : DELETE d FROM PL′ ;
And these rules are all, as I hope you'll agree, completely noncontroversial (though as in
Chapters 9 and 10 I think it's instructive to compare them with the rules I gave in connection
with the previous version of the example). So, to repeat from those previous chapters: In effect,
what I've done here is redesign the database in such a way that information that was previously
represented only implicitly, by the relvar names PL and PK, is now represented explicitly by
values of the attributes ON_SALE and IN_STOCK instead. And the effect of that redesign is to
convert the previous version of the example—viz., the version with at least arguably
unacceptable update behavior—into a version that behaves much more acceptably.
I'll leave it as an exercise to determine the implications of all of the foregoing for a user
who sees just relvar DLK′. As for defining DLK′ directly as a restriction of POI—which we
clearly could have done if we'd wanted to—I'll leave it as another exercise to show that the
behavior of such a restriction with respect to updates would be essentially identical to that of the
difference version as described above. Finally, I'll also leave it as an exercise to show that
(assuming it's supposed to be capable of supporting update operations properly) a “double
prime” version of the example—analogous to the “double prime” version of the counterpart
example, Example 2, in Chapter 9—is effectively a nonstarter.
A Remark on Included Difference
I'd like to consider, briefly, a slightly different example. Suppose we're given two relvars, PL
(giving, as above, part numbers for parts on sale) and PD (giving part numbers for parts
manufactured domestically), and there's a business rule in effect that says that only parts
manufactured domestically can be on sale—implying that, at all times, the relation that's the
current value of PL is included in the relation that's the current value of PD. Of course, the
difference DDL = PD MINUS PL gives part numbers for parts that are manufactured
 
Search WWH ::




Custom Search