Death to recursion! Re: Child vs parent records
Ed Kleban
Ed at Kleban.com
Sun Dec 11 10:00:17 CST 2005
On 12/11/05 9:31 AM, "Ruslan Zasukhin" <sunshine at public.kherson.ua> wrote:
> On 12/11/05 5:19 PM, "Ed Kleban" <Ed at Kleban.com> wrote:
>
>>
>> Unlike CreateForeignKeyLink, the CreateBinaryLink command can create 1:1,
>> 1:M, M:1, and M:M relations ships -- as you have frequently pointed out to
>> me. In this more generalized definition the concepts of "Parent" and
>> "Child" are less clear, may be irrelevant, and I would argue only offer an
>> opportunity for more confusion.
>
> IF BinaryLink is type 1 : M THEN we can use Parent-Child terminology.
>
> No difference to FK.
>
>
> But for M : M this not works! Right.
>
>
> Also note, that 1:1 (binary) link and M : M link on default do not know
> which table is owner.
>
> * Usually in 99% any of them is NOT owner.
>
> * we have symmetry
>
> * But if your task require you still can specify OWNER
>
Aha! Now there's a dimension I've been missing, and it explains much. You
are also trying to overload determination of which Table if either is the
owner when a link is defined. That's a whole different matter. And one I
hadn't really considered since in the apps I'm working with I never expect
to delete records.
I propose that the correct solution to this is to make ownership EXPLICIT
when you define the link. Namely:
CreateBinaryLink(
inName as String,
inLeftTable as VTable,
inRightTable as VTable,
inLeftPower as EVLinkType = kOne,
inRightPower as EVLinkType = kMany,
inOnDelete as EVOnDelete = kSetNull,
inStorageType as EVStorageType = kDefault,
inTemporary as Boolean = false,
inOwner as EVOwner = kLeftTable,
) as VBinaryLink
where enurations for EVOwner are:
kLeftTable, kRightTable, kNoOwner
Thus the left table is always the owner by default.
But as you say, for now it is always possible to simply state:
aNewlyCreatedBinaryLink.Owner = TableA
More information about the Valentina
mailing list