Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010

    Unanswered: Postgres in two tables

    Hello Everyone,

    Im currently learning about postgresql and I am encorporating JDBC to use my database as an extension to my website.

    Right now I have two tables, pupil and school,

    pupil has an id which is foreign and school has a primary key same ID.

    If I insert values into school, how can I make that automatically updated in foreign at one function?


  2. #2
    Join Date
    Jun 2004
    Arizona, USA
    If you UPDATE existing IDs in the school table, you can define the pupil foreign key to have cascading updates, but if you ADD new values in the school table, and NO current record in the pupil table can possibly reference it (as of the time you create the new school record) how could you possibly have records in the pupil table automatically update?

    Unless you want ALL records to update to the newest school id... (This would be done using a trigger, and is not something I think you would want to do...)
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts