Results 1 to 3 of 3

Thread: [RESOLVED] schema for storing polls

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Resolved [RESOLVED] schema for storing polls

    Hello,
    I have thought of using the schema explained below to store the poll questions, answers and votes received.
    1- Table 'poll_questions' - columns: id(primary key), question
    2- Table 'poll_answers' - columns: id(refers to id of poll_questions), answer, votes received. id+answer will be the primary key.
    Other option would be to have a separate table(poll_answers) to store the answers for each question and a table(poll_votes) to store the id of the question in poll_question and id of the answer in poll_answer and the actual number of votes received.
    Which is a better option among the ones mentioned by me? Would you suggest something else?
    Thank you.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: schema for storing polls

    Your schema is fine.

    Having a compound primary key in the poll_answer table is good form in my opinion.

    I see no reason to move the votes into another table - they simply relate to the answer for that question - so leaving them in the poll_answer table is also good form.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Location
    Hyderabad, India
    Posts
    233

    Re: schema for storing polls

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width