How do I Relate these 4 Tables

Posted by Baddie on Stack Overflow See other posts from Stack Overflow or by Baddie
Published on 2009-11-19T22:55:40Z Indexed on 2010/04/06 22:13 UTC
Read the original article Hit count: 360

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.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about entity-relationship