locked
Primary, Foreign Key RRS feed

  • Question

  • I have 2 tables, A and B.

    For A, it has 1 primary key and B has a foreign key which maps to table A primary key.

    If I develop a website, when I try to update table A, do my table B get update automatically?

    Or do I need to write the query for updating table A and B?

    Thursday, June 7, 2012 3:00 PM

Answers

  • When you say you are updating the record in the main table, you are not changing its primary key are you? Because that would break referential integrity. You can 'change' anything in table A you want, just not its ID or primary key.

    John Grove, Senior Software Engineer http://www.digitizedschematic.com/


    Thursday, June 7, 2012 3:03 PM

All replies

  • When you say you are updating the record in the main table, you are not changing its primary key are you? Because that would break referential integrity. You can 'change' anything in table A you want, just not its ID or primary key.

    John Grove, Senior Software Engineer http://www.digitizedschematic.com/


    Thursday, June 7, 2012 3:03 PM
  • On 6/7/2012 11:00 AM, Wen Hao Mui wrote:
    > I have 2 tables, A and B.
    >
    > For A, it has 1 primary key and B has a foreign key which maps to table
    > A primary key.
    >
    > If I develop a website, when I try to update table A, do my table B get
    > update automatically?
    >
    > Or do I need to write the query for updating table A and B?
    >
     
    The two tables are independent from each other in an update scenario.
    You can update either one without the need to do something with the other.
     
    Thursday, June 7, 2012 3:36 PM