wootscootinboogie
wootscootinboogie

Reputation: 8695

Change one field from a key in two related tables

I have two tables related by a composite primary key and one of the fields in the key needs to be changed. Can this be done without deleting the relationship and then re-establishing it after the value is changed?

myTable
    myTableID   CPK
    firstField  CPK  this needs to be changed
    secondField CPK

myOtherTable
    myOtherTableID
    myTableID CFK   this needs to be changed here
    firstField CFK
    secondField CFK

How can I update firstField from both tables simultaneously?

Upvotes: 1

Views: 60

Answers (1)

phadaphunk
phadaphunk

Reputation: 13313

You should read this article which explains how to make updates and transactions reflect on related tables.

Use the ON UPDATE CASCADE fro your specific case.

Hope this helps

Upvotes: 2

Related Questions