Results 1 to 3 of 3

Thread: [RESOLVED] Storing questions and choices

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Resolved [RESOLVED] Storing questions and choices

    Hi guys

    I am a bit stuck at this db design. The situation is, I have to store questions, their choices (fixed number - 4 choices) and the correct choice.

    Example:
    Code:
    What is your name ?
    - Hamsa
    - Koya
    - Akhilesh
    - Sasi
    I have come with three designs:

    1. Store the questions and answers in the same table
    Code:
    Table:Questions
    
    Questions(TEXT-2000) || Choice1(TEXT-500) || Choice2(TEXT-500) || Choice3(TEXT-500) || Choice4(TEXT-500) || Answer(VARCHAR-1)
    "Answer" will hold one of these values "1", "2", "3", or "4", which is the correct choice to that particular question.

    2. Store the choices separate and store the id of the choice in questions table
    Code:
    Table:Questions
    
    Questions(TEXT-2000) || Choice1(INT) || Choice2(INT) || Choice3(INT) || Choice4(INT) || Answer(INT)
    Code:
    Table:Choices
    
    id(INT) || Choice(TEXT-500)
    3. Store the choices separate and include the question id in the choices table for the relation
    Code:
    Table:Questions
    
    Question_ID(INT) || Questions(TEXT-2000)
    Code:
    Table:Choices
    
    Choice(TEXT-500) || Question_ID(INT) || is_answer(ENUM - 'true','false')
    Which one do you think as the best design ?

    I am using MySQL and in the above mentioned table designs, field names are followed by field type and size.

    I am expecting for a reason on accepting/rejecting each design(atleast a sentence), from your viewpoint.

    Thanks in advance

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Storing questions and choices

    tisk, sigh... for EACH? okay...
    1) least flexible... doesn't allow for more or less choices.
    2) Yeah, I didn't get that design
    3) most flexible - allows for varying amount of choices AND lends itself to randomization of the choices... all you need to know is which one is the right answer... you really don't (or at least you shouldn't) care if it is A or B or E....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Storing questions and choices

    Thanks
    Quote Originally Posted by techgnome View Post
    tisk, sigh... for EACH? okay...
    1) least flexible... doesn't allow for more or less choices.
    -tg
    Yeah, but there would be only 4 choices(fixed number).

    Quote Originally Posted by techgnome View Post
    tisk, sigh... for EACH? okay...
    2) Yeah, I didn't get that design
    -tg
    Yeah, that's a stupid design that I came up with.
    The idea was to separate choice into separate table and use that choiceID in the questions table.

    Quote Originally Posted by techgnome View Post
    tisk, sigh... for EACH? okay...
    3) most flexible - allows for varying amount of choices AND lends itself to randomization of the choices... all you need to know is which one is the right answer... you really don't (or at least you shouldn't) care if it is A or B or E....
    -tg

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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