If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Postgres in two tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-13-10, 13:52
omaiaa0p omaiaa0p is offline
Registered User
 
Join Date: Nov 2010
Posts: 1
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?

Thanks,
Reply With Quote
  #2 (permalink)  
Old 11-15-10, 13:04
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,817
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...)
__________________
Lou
使大吃一惊
"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

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On