开发者

Create automatically table that is composed by its primary key and 2 other foreign keys

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开发者_如何学C 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.


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

  • For PHP:
    • Doctrine
  • For .NET
    • NHibernate
    • There are a lot more of them
  • For Java:
    • Hibernate
    • Apache Cayenne
    • [..] And a lot more

You can find a pretty decent list of ORMs here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜