Re:Interbase parent-child table relations
On 7 Nov 1997 23:46:17 GMT, "Connie Okiro" <Ok...@compuserve.com>
wrote:
Quote
>> ..... (snip) ......
>I think the problem you are having is that the design you have created is
>Employee <-> Address <->Client, when you want
>Employee -> Address and
>Client -> Address.
>What you may want to do is include an Address ID in both the Employee and
>the Client table, retrieve the address ID after adding the address record
>and place it in the Employee or Client record (which ever one you are
>using).
>Connie
That could be a solution but how do you find the just-inserted
addresses's address ID? Use the address details to search the address
table? And if two addresses are virtually identical, which is possible
when two persons (or if a client is also an employee) share the same
address... And, in this last case, would you provide a mean to assign
the same address to several people? This can be tricky and so my
suggestion goes to composite keys.
The address table's key would be something like:
Type_of_person char(1)
/* C for client and E for employee */
ID_of_person integer
/* assuming both Employee and Client tables have this key
Address_Number smallint
/* sequential number (1 for first address, 2 for second, etc...) */
This structure is much more flexible and easy to maintain as you don't
need generators (and thus to retrieve the generated keys) for the
address table... The drawback is that, if you want to ensure
integrity, you have to enforce it through triggers...
Nuno
Nuno Leal
----
email: nl...@mail.telepac.pt