PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2012, 12:02 PM
yoda69 yoda69 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 17 yoda69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 11 m 22 sec
Reputation Power: 0
Design question

Hi all,
Before I'm starting to build my next project I wanted your advice on two issues:

A) I'm building a large survey (about 200-250 questions). I can do it in two ways:
1. Make a unique page for each question
2. Make one or two pages which will access the database in which the questions will be stored.

What's your opinion about making it a more secure and faster website?

B) Would you advice on making a large insert query at the end of the survey (that will include about 250 variables) or make several insert queries along the way? (update the row every 50 questions or so).

Thanks,

Reply With Quote
  #2  
Old July 9th, 2012, 03:26 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,696 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 4 h 42 m 31 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
A) #2. One page would be enough to handle everything, but you could separate it into two pages: one for showing questions, one for saving answers.
B) I would do an INSERT for the first "page" and UPDATES for the remainder. Advantages include getting a row into the table sooner and thus an ID, making it easier to save progress through the survey, and keeping track of complete versus incomplete results (starts off incomplete, marked as complete after the final set of questions).


How I would do it, given two minutes to think about it and not knowing the full story behind this project:

I could easily see grouping some questions together into distinct "pages" - for a short survey probably not but if you have >200 then probably so. So that's a new entity in the system: a "page of questions".
Code:
page_id | page_title
--------+---------------------
      1 | Personal Information
      2 | Favorite Things
      3 | Multiple Choice

There's also the questions themselves, of course...
Code:
question_id | page_id | question_text
------------+---------+--------------
          1 |       1 | Gender
          2 |       1 | Age
          3 |       2 | Favorite color

...and their possible answers.
Code:
answer_id | question_id | answer_text
----------+-------------+------------
        1 |           1 | Male
        2 |           1 | Female
        3 |           1 | Transgender
        4 |           1 | No answer
        5 |           2 | 1-18
        6 |           2 | 19-25

Then the place to put the chosen answers.
Code:
result_user | question_id | answer_id
------------+-------------+----------
          1 |           1 |         4
          1 |           2 |         7

(You'd also need a table for the users. This is for one survey per user: if you want multiple surveys then you'd need a table for users/results, and the table of chosen answers would use that as its foreign key.)

And there's the hard part out of the way.

Reply With Quote
  #3  
Old July 10th, 2012, 02:52 AM
Arugula905 Arugula905 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 78 Arugula905 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 22 h 7 m 34 sec
Reputation Power: 0
Quote:
A) I'm building a large survey (about 200-250 questions). I can do it in two ways:


you don't provide enough info, but more than 2 ways to do this...

a large survey is not <500 questions. but please provide a few...

let's do any survey:

you need to store the questions, kinda sorta. need to store to keep track. create a question db tbl

question table
q_id is sequencer/auto-inc(uniquely ids ?)
q_q is text AND the question, this is important.
//ignore these
q_type
q_order
q_cat
q_cnt
q_rel
q_dup

Then you need a survey table! Didya ever wonder why there are no OO DBs?

Ok, you don't define this well, but a survey should define:

the question(s) they include, perhaps order of the questions? and should be named(so we can keep track of the surveys?)

survey table
s_id is sequencer/auto-inc(uniquely ids ?)
s_name(bingo)
//ignore these
s_type
s_order
s_cat
s_cnt
s_rel
s_dup

About all you need? right?

Ok, let's go with your first survey? post back the questions, and we can populate the DB tbls and move on to the user interface(ui) and how people would actually be 'surveyed'.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Design question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap