Re: Constraints and Functional Dependencies

From: Jon Heggland <jon.heggland_at_idi.ntnu.no>
Date: Wed, 28 Feb 2007 08:40:03 +0100
Message-ID: <es3bkd$lt0$1_at_orkan.itea.ntnu.no>


Tony D wrote:
> I'm also not 100% convinced about the utility of possreps. What
> exactly do they get me that conversion functions don't, with fewer
> additional concepts ?

Convenience, tidyness, safety---there is no difference in power, though. It's a bit like encapsulation in OO (e.g. private/protected members in Java); it's not strictly necessary, but convenient.

With possreps, the conversion functions are in many cases implicit. Imagine you are to join two relations on a Length attribute. If you don't use possreps, and one relation uses inches and another centimeters, you have to remember to apply the correct conversion function. The DBMS has little chance to discover if you make a mistake.

If you use possreps, this is not an issue at all. You can compare two Lengths no matter what their actual representation is (cms or inches), without specifying how it is to be done. The possibility for mistakes is greatly reduced, since you don't have to remember what the actual representations are, or use explicit conversions.

Of course, some of these benefits may be gained without possreps too. You could introduce type safety into the conversion function scheme by defining two types, LengthInInches and LengthInCentimeters, and type safe conversion functions like InchesToCentimeters: LengthInInches -> LengthInCentimeters and so on. But you'd get a whole bunch of types. With possreps, you get just one type, but a whole bunch of possreps instead. I think it's tidier.

-- 
Jon
Received on Wed Feb 28 2007 - 08:40:03 CET

Original text of this message