Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:58:31+00:00 2026-06-18T09:58:31+00:00

I’m currently working on a survey creation/administration web application with PHP/MySQL. I have gone

  • 0

I’m currently working on a survey creation/administration web application with PHP/MySQL. I have gone through several revisions of the database tables, and I once again find that I may need to rethink the storage of a certain type of answer.

Right now, I have a table that looks like this:

survey_answers

id          PK
eid
sesid
intvalue    Nullable
charvalue   Nullable

id = unique value assigned to each row

eid = Survey question that this answer is in reply to

sesid = The survey ‘session’ (information about the time and date of a survey take) id

intvalue = The value of the answer if it is a numerical value

charvalue = the value of the answer if it is a textual representation

This allowed me to continue using MySQL’s mathematical functions to speed up processing.

I have however found a new challenge: storing questions that have multiple responses.
An example would be:

Which of the following do you enjoy eating? (choose all the apply)

  • Girl Scout Cookies
  • Bacon
  • Corn
  • Whale Fat

Now, when I want to store the result, I’m not sure of the best way to handle it.
Currently, I have a table just for multiple choice options that looks like this:

survey_element_options

id        PK
eid
value

id = unique value associated with each row

eid = question/element that this option is associated with

value = textual value of that option

With this setup, I then store my returned multiple selection answers in ‘survey_answers’ as strings of comma separated id’s of the element_options rows that were selected in the survey. (ie something like “4,6,7,9”) I’m wondering if that is indeed the best solution, or if it would be more practical to create a new table that would hold each answer chosen, and then reference back to a given answer row which in turn references back to the element and ultimately the survey.


EDIT

for anyone interested, here is the approach I ended up taking (In PhpMyAdmin Relations View):

Database Relationships and Table Structure

And a rudimentary query to gather the counts for a multiple select question would look like this:

SELECT e.question AS question, eo.value AS value, COUNT(eo.value) AS count
FROM survey_elements e, survey_element_options eo, survey_answer_options ao
WHERE e.id = 19
AND eo.eid = e.id
AND ao.oid = eo.id
GROUP BY eo.value
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:58:32+00:00Added an answer on June 18, 2026 at 9:58 am

    This really depends on a lot of things.

    1. Generally, storing lists of comma separated values in a database is bad, especially if you plan to do anything remotely intelligent with that data. Especially if you want to do any kind of advanced reporting on the answers.
    2. The best relational way to store this is to also define the answers in a second table and then link them to the users response to a question in a third table (with multiple entries per user-question, or possibly user-survey-question if the user could take multiple surveys with the same question on it.

    This can get slightly complex as a a possible scenario as a simple example:

    Example tables:

    • Users (Username, UserID)
    • Questions (qID, QuestionsText)
    • Answers (AnswerText [in this case example could be reusable, but this does cause an extra layer of complexity as well], aID)
    • Question_Answers ([Available answers for this question, multiple entries per question] qaID, qID, aID),
    • UserQuestionAnswers (qaID, uID)

    Note: Meant as an example, not a recommendation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.