INSERT in a ONE to ONE Relationship INSERT in a ONE to ONE Relationship sql sql

INSERT in a ONE to ONE Relationship


Here again my comment as an answer

since you have a reference in tableB and tableC to tableA, you have to insert tableA first and retreive the generated PK. Then you can insert in any of the other tables with the retrieved ID. For JPA have a look here: How to get Id of last persisted entity using JPA

And here is an example how to achieve this in sql server:http://sqlfiddle.com/#!3/a3f62/3

this is a basic in relational databases and foreign keys, i didnt read the wiki article, but it have to mention same the thinkg: http://en.wikipedia.org/wiki/Foreign_key