Referencing surrogate key

Posted by Arman on Stack Overflow See other posts from Stack Overflow or by Arman
Published on 2012-06-02T22:09:59Z Indexed on 2012/06/02 22:41 UTC
Read the original article Hit count: 179

Filed under:
|

I have a table that has an autoincrement surrogate key. I want to use it as a foreign key of my other table. The thing is, I cant figure out how I can reference it to that table, because it is nearly impossible to determine what I have to reference(the actual value of the surrogate key).

Please be noted that what I am trying to do is adding a tuple/record through my program(outside the dbms). The process is:

  1. Add a new record in Table1 and generate an autoincrement key. Update

  2. Add a new record in Table2 and reference its foreign key to the primary key of Table1. Update

My question is : HOW do I store the foreign key if I didnt know what is it?

© Stack Overflow or respective owner

Related posts about database

Related posts about foreign-keys