Re: Constraints and Functional Dependencies



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
.