开发者

O/R Mapping: One-to-One Id Column

开发者 https://www.devze.com 2023-03-04 19:37 出处:网络
I have to create two tables and objects with a o开发者_开发技巧ne-to-one relationship. Now I am wondering if it is better to use a foreign key in one of the tables, or whether I should use the primary

I have to create two tables and objects with a o开发者_开发技巧ne-to-one relationship. Now I am wondering if it is better to use a foreign key in one of the tables, or whether I should use the primary key of the first table as the primary key of the second table.

Any hints/advices?


I can't offer specific advice - I'm able to avoid questions like this in my own project because I use Fluent NHibernate (FNH) Automapping.

With FNH, you can automatically generate a database schema from an object model.

It will generate primary and foreign keys as necessary - I don't even have to think about it.

If your application will only have two tables, FNH is probably not worth the trouble, but for larger real world databases, I find it a much more productive way to work.

0

精彩评论

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