# Re: foreign key constraint versus referential integrity constraint

Date: Tue, 27 Oct 2009 13:41:48 -0300
Message-ID: <4ae722d1\$0\$26462\$9a566e8b_at_news.aliant.net>

Marshall wrote:

```>>Marshall wrote:
>>
>>>>>In a typed system, the type is whatever the intersection
>>>>>of int and string is.
>>
>>>>Union not intersection. It has to be a type compatible with both integer
>>>>and string.
>>
>>>I don't see how that would work. An integer isn't type compatible
>>>with a string. Is it?
>>
>>It doesn't have to be compatible with a string. It only has to be
>>compatible with TOP or the universal supertype. String doesn't have to
>>be compatible with integer either. It only has to be compatible with TOP
>>or the universal supertype.
```

>
> OK, I didn't get much sleep last night so I'm not very sharp, but
> I'll just regurgitate the argument I thought of before I went to
> bed:
>
> Consider relations A and B each with a single, common attribute.
> Natural join and inner union will behave much like intersection
> and union in this case. If the result type of the join isn't an
> intersection type, then we lose the property:
>
> A = A join (A union B)
>
> because the type of the attribute of the expression is different
> than the type of the attribute of A.

I don't see that you do. The type will be the MST of the resulting join. Because you will join A with a supertype of A, the MST will be the same as the type of A. This is different from the case joining an integer with a string because the MST is the universal supertype.

> More generally, the values in the result of a join are the
> intersection
> of the values in the operands; why wouldn't the result type be the
> intersection type?

I am not sure what you mean by the intersection type. If you join 2 types that are both supertypes of some set of subtypes, the resulting type will be the union type of those subtypes or the most specific supertype of those subtypes. In the case where there are no common subtypes, the resulting type will be the union type of the types themselves or the most specific supertype of them, and the body will be empty.

> Also, what about the analogous situation with inner union? Would
> the type of the common attributes be a union type or an intersection
> type? The values are the union of the values of the operands,
> so I would propose that it has to be a union type.

If you mean regular old union, the resulting type will be the most specific supertype, which might be a union type. If you union circles with hyperbola, the type will be conic sections. If you union circles with ellipses, the type will be ellipses.

```>>>Fortunately, I'm not hot any more. Now I'm thinking that
>>>I haven't had any alcohol in a week or more. Maybe
>>>a drink is in order? Plus, I think there is a cupcake in
>>>a cupboard somewhere downstairs. I must away!
>>
>>Having bathed each of my 3 dogs several times, I now have to wash the
>>skunk smell out of the vestibule before it pollutes the house any more
>>than it already has, when I would much rather just go to bed.
```

>
> Ouch! That sucks about the skunk.
>
> I skipped the drink but I found the cupcake. It was getting a
> bit on the dry side but still quite tasty! Now it's time for me
> to make my son some pancakes and send him off to school.

Original text of this message