Re: foreign key constraint versus referential integrity constraint
Date: Sun, 25 Oct 2009 11:40:45 -0300
paul c wrote:
> Bob Badour wrote:
>> paul c wrote: >> >>> Bob Badour wrote: >>> ... >>> >>>> You asked about semantic joinability. Semantically, the join works >>>> if like-named attributes have an equality comparison defined and not >>>> if they don't. >>>> ... >>> >>> In RT, how could they not define equality? >> >> What reason would one have to define an equality comparison to compare >> employee ids with department ids or with names? Or charge with current >> or potential? Or age with price?
> None in theory, I thought you were talking about attributes in the same
Nope. Natural join doesn't care about attributes in the same domain per se. It compares like named attributes regardless of domain.
TTM explains when and how the most specific types can differ and still have an equality comparison return true: they must share some common supertype other than the universal supertype. In this case, the MST of the join will be the most specific common supertype. If the MSTs of the original relations are mutually exclusive, the body will be empty. If not, the join body will consist of values drawn from subtypes of both MSTs and that appear in both relations.
Otherwise, the body of the join will be empty and the type of the like named attribute will be the universal supertype. As a type with a set of values and a set of operations, the universal supertype's set of values is the union of all values, and its set of operations is empty.
I expect most implementations would treat an attribute with the universal supertype as an error, or at least complain loudly with a warning. Received on Sun Oct 25 2009 - 09:40:45 CDT