Re: Proposal: 6NF
Date: Sat, 7 Oct 2006 13:15:50 +0300
Message-ID: <Pine.SOL.4.62.0610071246040.20588_at_kruuna.helsinki.fi>
> SELECT COUNT(1)
> FROM Animals
> ANTIJOIN Layers
> ON Animals.id = Layers.id
> WHERE Layers.eggs > 5
That will work, and I already tried to say as much. You can have two views, one with all the animals and only the columns that are common to all the animals (the inner union suggested by Marshall), and one with the single attribute you need for this query plus a key that is shared by all animals. As a general principle, you'll end up with an inner union view for each class containing it and all of its subtypes, and you'll also need a similar view for each attribute containing all of the types it appears in. If you apply multiple inheritance willy nilly, eggs_laid could be used with robotic chicken, which are machines, not animals, so in general you'd need to key your entities with oid's so that you can always be sure that a join between a class and an attribute table has a common key to work on. This is fine by me: I have nothing against surrogates.
It's just that I find all of the above a bit excessive when you can use nulls in the class views, drop the attribute ones and make do without joins. Right now I think we're downto matters of taste and usability, and I refuse to believe that code involving theta-antijoins is significantly easier to get right than
select count(1) from animals where eggs_laid<5 or eggs_laid is null
-- Sampo Syreeni, aka decoy - mailto:decoy_at_iki.fi, tel:+358-50-5756111 student/math+cs/helsinki university, http://www.iki.fi/~decoy/front openpgp: 050985C2/025E D175 ABE5 027C 9494 EEB0 E090 8BA9 0509 85C2Received on Sat Oct 07 2006 - 12:15:50 CEST