开发者

Separate class for foreign key constraints?

For an example object with fields

Books
-----
ID
AuthorID
Qua开发者_高级运维ntity
ISBN
PublisherID

The 2 foreign key constraints correspond to Author Name & Publisher Name from 2 other tables.

  1. For viewing the said object in a listview, is it recommended to create 2 additional fields (AuthorName,PublisherName) inside the same class or to create a separate object with 2 fields and inherit other fields from the Books class ?
  2. What is the standard to follow for such scenarios inside enterprise applications ?

Damien.


I subscribe to the school of thought that you do not query an object model.

Your problem immediately evaporates :)

What I would do is use a simple query layer to return the data I need. In fact, I prefer a denormalized query store and if that isn't possible I will try to denormalize the table I am querying when doing inserts/updates and as a last resort I will use a join.

You may want to take a look at CQRS.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜