473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DB design question - survey system

DFS
I've written several survey systems in which the majority of the questions
have the same or similar responses (Yes/No, True/False, scale of 1 - 5,
etc).

But this latest survey system I'm working on has 8-10 sections, with a
variety of question attributes and answer scales. Some items have just a
description and require a Yes/No answer, others have a description and an
active status and require a Yes/No and price answer, some require a comment,
etc.

Rather than build a separate response table for each survey section, I was
thinking of building one generic response table, and trying to force all
sections to fit by adding columns - some of which won't apply to some items.
Like this:

Survey Category (will apply to all items)
Survey Section (will apply to all items)
Item Description (will apply to all items)
Item YN (will apply to all items)
Item Price (will apply to about 10% of the items)
Item Points (will apply to about 10% of the items)
Item Active YN (will apply to about 10% of the items)
Item Fail YN (will apply to about 10% of the items)
Item Comment (will apply to about 10% of the items)

For instance, in the structure above the field "Item YN" would represent
multiple types of answers: is the item in use?, is the item in place?, is
the item given away for free?, is the item on display?, etc. Basically,
anywhere a Yes/No answer is used.

The advantage is one source table (rather than 8) for storing answers, and
it might be easier to query and report on.

The disadvantages I see are 1) it's more difficult to understand the meaning
of the responses when the answer field is named Item YN, and 2) you have a
non-normalized table that's difficult for a 3rd party to understand.

If I have the questions and responses in separate tables, I'll use names
like "ItemComplimentaryYN" and "ItemUsedYN" depending on the question. It's
easier for others to learn the data.

I actually don't like the "generic" approach, and probably won't use it, but
I figured I'd try to get some input from others who've written survey
systems.

Thanks

Nov 13 '05 #1
5 1672
Normalize.

You didn't explain how the survey is being generated, but that they may
not matter. However, if this is a web application that builds dynamic
forms, experience indicates the best solution is to provide a form
builder via an Admin application.

Store the meta-data about your forms and provide an interface for
adding form meta-data via building and modifying forms. Whenever a
form is created or updated, generate the form (asp, aspx, whatever)
using a Generator Service that monitors a queue. The queue gets PUSHes
from the Admin application whenever something triggers a form
regeneration, and the responsibility of the Generation Service is to
POP the queue and generate forms from the meta-data. You also want to
add the feature to generate sets of forms based on the results of a
stored procedure.

I suggest building the queue in SQL Server. Most developers lean
towards MSMQ, however the problem with MSMQ is that it has limited
interfaces - you can't POP and PUSH with Transact SQL. We migrated a
queue that runs 24x7 capturing data from our customers for their sites
from a 3rd party queue product to SQL Server . We have implemented
MSMQ in other areas of our organization, however we are migrating them
to SQL Server.

Our software runs about 5,000 sites and we provide our site
administrators the ability to build forms that capture normalized data.
Within five seconds after an administrator builds or modifies the
form, the new form is on their site (which is on a 15-server farm)
capturing and redirecting normalized data based on business rules for
the recipient(s).

Nov 13 '05 #2
Hi

You talk about a single table per section, but I am not sure that that sort
of design would be any different to your suggested one.

You could have a separate table for each type of questions i.e have all Y/N
answers in one table, also Fail/Active/Nothing/Complementary can be a second
attribute therefore you will not have separate columns for the Y/N part.

You may also want to check out using SQL_VARIANT as a data type.
http://msdn.microsoft.com/library/de...asp?frame=true

Full text searching would possibly be a different solution.

John

"DFS" <no****@nospam.com> wrote in message
news:41*****************@fe07.lga...
I've written several survey systems in which the majority of the questions
have the same or similar responses (Yes/No, True/False, scale of 1 - 5,
etc).

But this latest survey system I'm working on has 8-10 sections, with a
variety of question attributes and answer scales. Some items have just a
description and require a Yes/No answer, others have a description and an
active status and require a Yes/No and price answer, some require a
comment,
etc.

Rather than build a separate response table for each survey section, I was
thinking of building one generic response table, and trying to force all
sections to fit by adding columns - some of which won't apply to some
items.
Like this:

Survey Category (will apply to all items)
Survey Section (will apply to all items)
Item Description (will apply to all items)
Item YN (will apply to all items)
Item Price (will apply to about 10% of the items)
Item Points (will apply to about 10% of the items)
Item Active YN (will apply to about 10% of the items)
Item Fail YN (will apply to about 10% of the items)
Item Comment (will apply to about 10% of the items)

For instance, in the structure above the field "Item YN" would represent
multiple types of answers: is the item in use?, is the item in place?, is
the item given away for free?, is the item on display?, etc. Basically,
anywhere a Yes/No answer is used.

The advantage is one source table (rather than 8) for storing answers, and
it might be easier to query and report on.

The disadvantages I see are 1) it's more difficult to understand the
meaning
of the responses when the answer field is named Item YN, and 2) you have a
non-normalized table that's difficult for a 3rd party to understand.

If I have the questions and responses in separate tables, I'll use names
like "ItemComplimentaryYN" and "ItemUsedYN" depending on the question.
It's
easier for others to learn the data.

I actually don't like the "generic" approach, and probably won't use it,
but
I figured I'd try to get some input from others who've written survey
systems.

Thanks

Nov 13 '05 #3
DFS wrote:
I've written several survey systems in which the majority of the questions
have the same or similar responses (Yes/No, True/False, scale of 1 - 5,
etc).

But this latest survey system I'm working on has 8-10 sections, with a
variety of question attributes and answer scales. Some items have just a
description and require a Yes/No answer, others have a description and an
active status and require a Yes/No and price answer, some require a comment,
etc.


Do use one table for answers. I mean for questions. There may be some
frame you need around this table; but I feel, and then I mean my
database intuition, that one table is the best way to get statistics and
reports.

Let me think aloud.

If one question can have an answer in more parts, that troubles the
setup. You mention yes/no and a price answer; but is this the type "No"
or "Yes, namely $32" ? In that case the yes/no part can be made implicit.

What you can use is some tag, indicating the meaning of the answer
value. I see this table before my eye:

Question( [ID,] questionNumber, questionText, answerType, answerTag)

Decide for yourself if the questionnumber would be the primary key, or
you use a separate, non-user-visible key (I prefer the latter).

answerType sits in a small table, containing values like
{"yes/no","number","text"}--much like the DataType of a field. You have
this table, appropriately called AnswerType, one-to-many to the question
table. Btw I name my tables single rather than plural. That's a choice.

answerTag can be any description that differentiates to you what kind of
datum the answer represents.

So far this structure can produce empty survey forms.
Real surveys provide answers; you might store those in

Survey(surveyID)
SurveyAnswer(surveyID, questionNumber, givenAnswer)

where you can derive the properties of givenAnswer from the Question table.

I recommend the generic approach. It enables you to change the survey
setup without data changes, it does take some getting used to as it is a
little more abstract than the straight table but once you get the hang
of it you won't want something else anymore ;-)
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4
DFS
ma**@msn.com wrote:
Normalize.

You didn't explain how the survey is being generated, but that they
may not matter. However, if this is a web application that builds
dynamic forms, experience indicates the best solution is to provide a
form builder via an Admin application.

Store the meta-data about your forms and provide an interface for
adding form meta-data via building and modifying forms. Whenever a
form is created or updated, generate the form (asp, aspx, whatever)
using a Generator Service that monitors a queue. The queue gets
PUSHes from the Admin application whenever something triggers a form
regeneration, and the responsibility of the Generation Service is to
POP the queue and generate forms from the meta-data. You also want to
add the feature to generate sets of forms based on the results of a
stored procedure.

I suggest building the queue in SQL Server. Most developers lean
towards MSMQ, however the problem with MSMQ is that it has limited
interfaces - you can't POP and PUSH with Transact SQL. We migrated a
queue that runs 24x7 capturing data from our customers for their sites
from a 3rd party queue product to SQL Server . We have implemented
MSMQ in other areas of our organization, however we are migrating them
to SQL Server.

Our software runs about 5,000 sites and we provide our site
administrators the ability to build forms that capture normalized
data. Within five seconds after an administrator builds or modifies
the form, the new form is on their site (which is on a 15-server farm)
capturing and redirecting normalized data based on business rules for
the recipient(s).


Awesome answer, maxl. Thanks.

It's an Access application, so I use a variety of Access tab controls and
forms: datasheet and continuous view mainly. The surveys are slightly
dynamic, in that an administrator will be revising the questions, points,
items, etc and pushing the new survey data down to the field each week or
so.

The survey itself is generated at run-time, by the user, from lookup tables
containing the questions. I copy the questions (necessary parts anyway) and
items into survey tables, along with a unique ID for the survey instance.

I want to do some web survey systems, but I can deliver this one much
quicker under Access. And with only 5 to 6 users, code updates and
distribution isn't an issue.

Thanks for your help.

Nov 13 '05 #5
DFS
John Bell wrote:
Hi

You talk about a single table per section, but I am not sure that
that sort of design would be any different to your suggested one.
Well, I was considering aggregating all responses into one table. As I
described, it would require the addition of several columns that are
irrelevant to 90% of the questions. The result would be a non-normalized
mess, though it would probably be easier to query and report on.

You could have a separate table for each type of questions i.e have
all Y/N answers in one table, also Fail/Active/Nothing/Complementary
can be a second attribute therefore you will not have separate
columns for the Y/N part.
Interesting. That's kind of in-between where I am now and my "generic"
approach under consideration. I'll look into this a little more. I do have
some tables with similar response types I could combine.

You may also want to check out using SQL_VARIANT as a data type.
http://msdn.microsoft.com/library/de...asp?frame=true

It's an Access system, so text would be my only real option if I wanted to
combine response types into one column.
Thanks for your help.
Full text searching would possibly be a different solution.

John

"DFS" <no****@nospam.com> wrote in message
news:41*****************@fe07.lga...
I've written several survey systems in which the majority of the
questions have the same or similar responses (Yes/No, True/False,
scale of 1 - 5, etc).

But this latest survey system I'm working on has 8-10 sections, with
a variety of question attributes and answer scales. Some items have
just a description and require a Yes/No answer, others have a
description and an active status and require a Yes/No and price
answer, some require a comment,
etc.

Rather than build a separate response table for each survey section,
I was thinking of building one generic response table, and trying to
force all sections to fit by adding columns - some of which won't
apply to some items.
Like this:

Survey Category (will apply to all items)
Survey Section (will apply to all items)
Item Description (will apply to all items)
Item YN (will apply to all items)
Item Price (will apply to about 10% of the items)
Item Points (will apply to about 10% of the items)
Item Active YN (will apply to about 10% of the items)
Item Fail YN (will apply to about 10% of the items)
Item Comment (will apply to about 10% of the items)

For instance, in the structure above the field "Item YN" would
represent multiple types of answers: is the item in use?, is the
item in place?, is the item given away for free?, is the item on
display?, etc. Basically, anywhere a Yes/No answer is used.

The advantage is one source table (rather than 8) for storing
answers, and it might be easier to query and report on.

The disadvantages I see are 1) it's more difficult to understand the
meaning
of the responses when the answer field is named Item YN, and 2) you
have a non-normalized table that's difficult for a 3rd party to
understand.

If I have the questions and responses in separate tables, I'll use
names like "ItemComplimentaryYN" and "ItemUsedYN" depending on the
question. It's
easier for others to learn the data.

I actually don't like the "generic" approach, and probably won't use
it, but
I figured I'd try to get some input from others who've written survey
systems.

Thanks

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: franz | last post by:
Hi developers! Are you using design pattern? And do you want to help me with my research project? Ok – you only need two minutes – I made a little survey form (8 very short questions). There...
0
by: Kenzo Fong | last post by:
Hi everyone, Sorry to fill up this newsgroup with this request, but for coursework at Erasmus University (the Netherlands) I need to conduct a survey regarding the use of certain open source...
5
by: DFS | last post by:
I've written several survey systems in which the majority of the questions have the same or similar responses (Yes/No, True/False, scale of 1 - 5, etc). But this latest survey system I'm working...
2
by: JG | last post by:
I am a developer and I have a problem trying to design a system to manage data coming from web surveys. Each section can potentially have dozens of questions, i.e., fields. I am focusing here only...
15
by: kimi | last post by:
I have just started working on a project that is partially complete. It is an application that is using access to store test results. The test results are being stored in two Access 2000 databases....
0
by: Joerg Rech | last post by:
Dear software practitioners, consultants, and researchers, we are currently conducting an international survey about architecture and design patterns. Our goal is to discover how familiar people...
0
by: Joerg Rech | last post by:
Dear software practitioners, consultants, and researchers, we are currently conducting an international survey about architecture and design patterns. Our goal is to discover how familiar people...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
0
by: Janet93 | last post by:
If you are involved in the development of scientific computing software, you are invited to participate in a survey on developing this kind of software. If you have already received this request, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.