Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Hi,

    Im new to all this so this MySQL stuff may be a daft question.

    Im making a large registration form for one of my sites and most of the entries on the form are straight forward questions with 1 answer which can be easily stored within the MySQL DB. However for one of my questions there is a large list of possible answers and the user can select as many as they want.

    My question is should I store the responses to this question in one cell of the DB seperated with commas or should I setup a column in the database for each of the possible answers for that question and then just store a true or false value for each one?

    Are there any obvious benefits from doing it either way?

    Thanks

  2.  

  3. #2
    Senior Member
    Join Date
    Dec 2009
    Location
    Chicago, IL
    Posts
    114
    Member #
    20579
    Liked
    2 times
    You could either store all of the answers as an array, or you can have a separate table for that question, and join it to another table via an ID of sorts. Or you can have a separate table just for answers to the questions. Lets assume that you have a question #4 on your form that has multiple available answers. Your return table would look something like this:


    AnswerID QuestionID UserID Answer
    1 1 1 true
    2 2 1 false
    3 3 1 false
    4 4 1 baseball
    5 4 1 football
    6 4 1 hockey

    You can store multiple users' answers in this table, and it would allow you to query easily in order to recognize trends. The AnswerID would be an auto-incremented unique number, and is sort-of irrelevant to you, but good practice to include. notice the last three rows are three answers to 1 question by the same user. does that make sense?

  4. #3
    Senior Member
    Join Date
    Dec 2009
    Location
    Chicago, IL
    Posts
    114
    Member #
    20579
    Liked
    2 times
    Sorry, I couldn't get that table to format better.

  5. #4
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Thanks for the advice, I was just thinking about creating a seperate table for that question. I think this would be easier as Im am starting to get a grip on creating and linking tables but dont really know much about working with arrays.

    Thanks again


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:08 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com