Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Other SQL Server Topics / August 2005

Tip: Looking for answers? Try searching our database.

Web Survey database design

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JG - 25 Aug 2005 22:55 GMT
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 on the table(s) that will hold the survey data.
I do not have any DDL as I am still trying to understand this!
All the examples I have found so far in books and on the web seem to
deal with fairly limited data, that is easily, or so it looks, broken
down in multiple tables.
It seems that, from my research, having a wide table per survey section
with each field as a column, which has been suggested to me, is not
proper design for many reasons - missing values for non-required
questions, table with 100s of possible columns, etc... - so I played
with the idea of a single table where one of the columns would be the
foreign key pointing to a questions table and another column would hold
the data (this is a simplified explanation.)
The problem with this is that now this column will have to accomodate
all types of data, from bits to large varchars, and that field
validation seems now impossible jeopardizing data integrity.

What do knowledgeable designers come up with in this case? Can someone
point me in the right direction?

Jerry
Erland Sommarskog - 26 Aug 2005 23:23 GMT
> 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
[quoted text clipped - 11 lines]
> foreign key pointing to a questions table and another column would hold
> the data (this is a simplified explanation.)

Yes, I would very much advocate this design.

> The problem with this is that now this column will have to accomodate
> all types of data, from bits to large varchars, and that field
> validation seems now impossible jeopardizing data integrity.

You could make that column sql_variant. This data type can fit any
other SQL Server data type except text, ntext and image.

In order to prevserve integrity, you can for each question define which
datatype that is correct for that question. In the trigger of the answers
table, you can check with sql_variant_property() that the data type is
correct.

Signature

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

JG - 30 Aug 2005 20:58 GMT
Erland,

thank you very much for your reply.
It is good to know this is the right way!
I didn't know about the sql_variant type so this is really helpful.
In my search I found a site that also seemed to confirm this design.
The interesting thing is they separate the free text answers from the
'pointer' answers (such as radio buttons, drop-downs, etc...), what
they call 'multiple-choice_questions':
http://www.databaseanswers.org/data_models/questionnaire_complex/index.htm

Jerry
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.