开发者

How to design discussion for multiple entities

I've got entities like Project, Client, Task, and every one of them should have list of posts(aka discussion). Problem is that since every entity(project, client,..) is mapped to it's own table, i can't refer that entity from discussion by "owner_id" because it'd be ambigious having client with id=1 and project with id=1 and discussion wouldn't know if it belongs to project or client. I'd like to avoid having independent discussion entity for client and another independend discussion entity for project .. (cause later on i might want to add discussion to another entity so it's no开发者_开发技巧t really "scalable"). I know that i can add discriminator attribute(column) to discussion that would distinguish between clientDiscussion and projectDiscussion. I'm wondering if that's the right way to do such thing or not. what do you tink?


Personally it sounds like you need to create an abstract entity.

EntityType<-Entity<-EntityDiscussion->Discussion

How to design discussion for multiple entities

How different are the fields in Project/Client/Task?


Can a discussion be only about a single entity? If so then your use of a discriminator is an approach I've seen used, you've outlined why the obvious alternative is not useful for you.

My instinct is that in the real world Discussions don't always refer to a single kind of thing. So you might need a Topics entity too, with Discussions having many Topics, still leaving you with the need for a discriminator.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜