Subject Re: [IBO] Transaction with master-child relationship
Author Helen Borrie
At 09:07 AM 8/12/2003 +0000, you wrote:
>--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> > At 07:03 AM 8/12/2003 +0000, you wrote:
> > >Hi,
> > > I encounter a *scratch-head* reaction with my master-child
> > >relationship transaction. My master and child tables are CUSTOMER
>and
> > >ADDRESS respectively. I've set their relationship according to the
> > >TransactionsHandling tutorial lesson 2.
> > >
> > >Info on child IB_Query:
> > > MasterLinks: ADDRESS.ID=CUSTOMER.CUST_ID
> > > MasterSource: DSCustomer
> >
> > Are you sure this relationship is correct? Surely, your detail-to-
>master
> > link should be through a foreign key in the ADDRESS table -
>ADDRESS.CUST_ID
> > or something similar. ADDRESS.ID seems like it would be the
> > **primary key** of the address table....
>
>The primary key of ADDRESS table is (ID, ENTITY, ADDRESS_TYPE). I
>intend to use this table to store addresses of customers, vendors and
>etc. Therefore I have the ENTITY field to identify the address is for
>what kind of entity. ID will be the ID of that entity. ADDRESS_TYPE
>will be either 'Billing', 'Delivery' and etc.
>
>I did not create a foreign key in my ADDRESS table because I can't.
>This table *references* different tables based on the ENTITY field.
>
>Do you mean the absence of a foreign key is the reason why it won't
>work?

The *wrong* key would prevent it from working. But if this ADDRESS.ID
column carries the PK of the CUSTOMER table, it should be OK.

The next place to look is the KeyLinks of the ADDRESS query. Do you have
*all* of its primary key columns in KeyLinks? And make sure that the
KeySource property of the detail dataset is Nil.

Helen