Board index » delphi » Changing Key Fields in Master Record without Orphaning Detail Records

Changing Key Fields in Master Record without Orphaning Detail Records

I have a form with multiple tables on it, linked in a One->Many
Relationship.  My question is, what is the best way to handle users
editing the key value in the Master table without orphaning records in
the Detail tables.

Thanks in Advance,

Dean.

 

Re:Changing Key Fields in Master Record without Orphaning Detail Records


Quote
Dean Millam <cull0...@gold.tc.umn.edu> wrote:
>I have a form with multiple tables on it, linked in a One->Many
>Relationship.  My question is, what is the best way to handle users
>editing the key value in the Master table without orphaning records in
>the Detail tables.

>Thanks in Advance,

>Dean.

It's called 'referential integrity'. Of the native desktop databases in
Delphi,only Paradox supports referential integrity with cascading
updates, which is exactly what you want. Access databases support both
cascading updates and cascading deletes. SQL servers usually require that
you set up triggers for cascading updates or deletions. Interbase is no
exception.

Look in the documentation for the above subjects.

Good Luck,
Peter Antypas
paa00...@bayou.uh.edu

Re:Changing Key Fields in Master Record without Orphaning Detail Records


In <30FCD87F....@gold.tc.umn.edu> Dean Millam

Quote
<cull0...@gold.tc.umn.edu> writes:

>I have a form with multiple tables on it, linked in a One->Many
>Relationship.  My question is, what is the best way to handle users
>editing the key value in the Master table without orphaning records in
>the Detail tables.

>Thanks in Advance,

>Dean.

I don't know if my previous reply was sent since I got some silly
error.

Please check the help file on Referential Integrity in DBD.  That
should solve your problem.
Ben
Arrow

Re:Changing Key Fields in Master Record without Orphaning Detail Records


In <30FCD87F....@gold.tc.umn.edu> Dean Millam

Quote
<cull0...@gold.tc.umn.edu> writes:

>I have a form with multiple tables on it, linked in a One->Many
>Relationship.  My question is, what is the best way to handle users
>editing the key value in the Master table without orphaning records in
>the Detail tables.

>Thanks in Advance,

>Dean.

Here is a snippet from the Database Desktop help file on Referential
Integrity.  This should resolve your orphanage problem.

Update Rule

With the Child Fields and the Parent's Key in the diagram area, choose
the update rule you want. Database Desktop provides two update rules
for tables that use referential integrity. You must use one of these
rules:

Cascade If you choose Cascade, any change you make to the value in
Parent's Key is automatically made in the table it is linked to by
referential integrity. Cascade is Database Desktop's default update
rule.
        Note: To cascade an update across tables, Database Desktop must
place a lock on the target table. If the lock is denied (because
another user has already placed a lock), Database Desktop cannot
perform the cascade update

Other Threads