1 Reply Latest reply on Jul 2, 2014 5:56 AM by philmodjunk

    Update child foreign keys when updating parent primary key

    AlbertoPilato

      Title

      Update child foreign keys when updating parent primary key

      Post

           Hi,

           I've tried searching but I didn't find an answer.

           I have a master table with 3 related child tables.

           If I update the master primary key I end up losing the connection with its child tables.

           How do I make FileMaker to update foreign keys on child tables when I update the primary key on the master?

           Thanks in advance,

           Alberto

        • 1. Re: Update child foreign keys when updating parent primary key
          philmodjunk

               If it's a primary key, the value of that field should never, ever be updated and thus this issue never occurs.

               The ideal primary key is:

                 
          1.           Always unique in the table where it is defined.
          2.      
          3.           Never, ever changed once assigned to a new record in the table where the key is defined.
          4.      
          5.           Never includes any additional "encoded meaning" beyond that "unique identification" in 1.
          6.      
          7.           Is implemented in as simple and "bullet proof" a fashion as possible.


               That's why most properly set up primary keys in FileMaker databases are auto-entered serial numbers and a smaller subset use Get ( UUID ).

               But to answer the question, you would retain the links by updating the foreign key fields of the related records to the new value first, then update the primary key value of the parent record.