Referencing surrogate key
- by Arman
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:
Add a new record in Table1 and generate an autoincrement key. Update
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?