views:

41

answers:

1

I have table A with a primary id, a table B with a primary key id also and another table C with a primary key id and rows Aid and Bid where Aid and Bid are foreign keys of C and the primary keys of A and B respectively.

One way of populating these DB would be populating table A, table B and table C separately.

I would like to know if there is a more clever way of doing it, where I could populate A first and at the same time I populate B, I can indicate that an entry in C should be also created.

Any idea and suggestion on how to populate them is welcome. I'm trying to take advantage of the foreign keys structure.

Thanks.

+1  A: 

You could use an ORM that will analyze your structure and create this for your. Examples of ORMs are:

You can find a pretty decent list of ORMs here.

PatrikAkerstrand
Thanks. I'm using Python, but i'm not familiar with ORMs. I'm afraid that setting it up and leaning it would be more expensive than implementing it in the simplest way (every table separately)
duduklein