开发者

How do I Relate these 4 Tables

Trying to setup a simple Thread/Poll table mapping.

Here is what I have:

Threads table

  • ThreadID (Primary Key/Identity Column)

Polls table

  • PollID (Primary Key, FK for ThreadID for one-to-one relation)
  • Question

PollOptions table

  • PollOptionID (Identity/Primary Key)
  • Text
  • PollID

PollVotes table

  • PollVoteID (Primary Key/Identity)
  • PollOptionID

I'm not sure if this is a proper relationship. It seems wrong but I'm not sure whats wrong with it.

A Thread can have 0 or 1 Poll.

A Poll can have 2 or more PollOptions.

A PollOption can have 0 or many PollVotes.

I'm going to be using Entity Framework and before I generate the code for it (VS 开发者_高级运维2010, .NET 4) I want to make sure I have the proper relationship mapping.


Maybe I'm misreading your relation there, but it seems like relating Poll to Thread would make more sense than Thread to Poll, since you have a 0 or 1 relationship with Thread to Poll. Otherwise I think your relationships look fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜