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

  • Home
  • SEARCH
  • 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 102129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:54:15+00:00 2026-05-11T00:54:15+00:00

Greetings stackers, I’m trying to come up with the best database schema for an

  • 0

Greetings stackers,

I’m trying to come up with the best database schema for an application that lets users create surveys and present them to the public. There are a bunch of ‘standard’ demographic fields that most surveys (but not all) will include, like First Name, Last Name, etc. And of course users can create an unlimited number of ‘custom’ questions.

The first thing I thought of is something like this:

Survey   ID   SurveyName  SurveyQuestions   SurveyID   Question  Responses   SurveyID   SubmitTime  ResponseAnswers   SurveyID   Question   Answer 

But that’s going to suck every time I want to query data out. And it seems dangerously close to Inner Platform Effect

An improvement would be to include as many fields as I can think of in advance in the responses table:

Responses   SurveyID   SubmitTime   FirstName   LastName   Birthdate   [...] 

Then at least queries for data from these common columns is straightforward, and I can query, say, the average age of everyone who ever answered any survey where they gave their birthdate.

But it seems like this will complicate the code a bit. Now to see which questions are asked in a survey I have to check which common response fields are enabled (using, I guess, a bitfield in Survey) AND what’s in the SurveyQuestions table. And I have to worry about special cases, like if someone tries to create a ‘custom’ question that duplicates a ‘common’ question in the Responses table.

Is this the best I can do? Am I missing something?

  • 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. 2026-05-11T00:54:15+00:00Added an answer on May 11, 2026 at 12:54 am

    Your first schema is the better choice of the two. At this point, you shouldn’t worry about performance problems. Worry about making a good, flexible, extensible design. There are all sorts of tricks you can do later to cache data and make queries faster. Using a less flexible database schema in order to solve a performance problem that may not even materialize is a bad decision.

    Besides, many (perhaps most) survey results are only viewed periodically and by a small number of people (event organizers, administrators, etc.), so you won’t constantly be querying the database for all of the results. And even if you were, the performance will be fine. You would probably paginate the results somehow anyway.

    The first schema is much more flexible. You can, by default, include questions like name and address, but for anonymous surveys, you could simply not create them. If the survey creator wants to only view everyone’s answers to three questions out of five hundred, that’s a really simple SQL query. You could set up a cascading delete to automatically deleting responses and questions when a survey is deleted. Generating statistics will be much easier with this schema too.

    Here is a slightly modified version of the schema you provided. I assume you can figure out what data types go where 🙂

         surveys       survey_id (index)       title      questions       question_id (index, auto increment)       survey_id (link to surveys->survey_id)       question      responses       response_id (index, auto increment)       survey_id (link to surveys->survey_id)       submit_time      answers       answer_id (index, auto increment)       question_id (link to questions-question_id)       answer 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 143k
  • Answers 143k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you don't specify the connection it will use the… May 12, 2026 at 8:28 am
  • Editorial Team
    Editorial Team added an answer Something like: $('img.thumb').click(function() { var src = $(this).attr('src'); $('#bigImage').attr('src', src.replace(/-thumb/,''));… May 12, 2026 at 8:27 am
  • Editorial Team
    Editorial Team added an answer If you want to avoid undocumented api you can also… May 12, 2026 at 8:27 am

Related Questions

Greetings stackers, I'm trying to come up with the best database schema for an
Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings. I'm looking for a way to parse a number of XML files in
Greetings! I'm working on wrapping my head around LINQ. If I had some XML
Greetings, I'm trying to find either a free .NET library or a command-line executable

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.