Suppose you’re a college student performing a research project. Part of that research is a survey with several types of questions. To make your life easier, you’ve decided to create a small web application to ask the questions and record the answers — this also gives you a SQL database you can query to analyze the results.
(No, I’m not a college student — a friend is and the question stumped me.)
The simple implementation is to use a multiple-choice system for recording questions. Unfortunately, the specification for the questions doesn’t allow this. Obviously there are several entities in the database: questions, surveys (collections of questions), responses (collections of answers). The problem is mapping questions to responses.
There are two types of questions and three types of responses.
Boolean, Free Response, and Rating
Given the idiom to kick the bucket…
Q: Have you heard this idiom before in any context?
Q: Describe a situation in which use of the idiom would be appropriate in no more than 1-2 sentences.
A: Free response
Q: How certain are you of your response?
A: Scale of 1-4 (1=very uncertain, 2=somewhat uncertain, 3=somewhat certain, 4=very certain).
A random sample received instructions to read an idiom and instructed to “describe a situation in which use of the idiom would be appropriate in no more than 1-2 sentences.” Rate the creativity of the responses on a scale of 1-5 (1=very uncreative, 5=very creative).
Q: Idiom: to kick the bucket. Response: You would use this when someone dies.
A: Scale of 1-5
Should there be other entities? Should a question have multiple parts? How do you encode the type of a response in the database in a sensible way without moving too much of the business logic out of the database?
I’m not sure how to answer these design questions — thus it seems like a good puzzler to start some discussions.