how to store page breaks

From: drew <spamduster_at_yahoo.com>
Date: 16 May 2003 10:48:49 -0700
Message-ID: <af3437fb.0305160948.3e0f1d28_at_posting.google.com>



I have a survey application where questions of a given survey are displayed in a certain order based on a sort field, and grouped in
"pages" (or sections) based on...?

Method 1:

Add a "page break" field in the question table that essentially says
"if page break field==true, then a page break belongs after this
question." With the javascript controlled select box I use to re-order questions and insert page breaks, the page break would appear de-coupled from the question, allowing the user to move the question up or down without worrying that the page break is going with it.

Displaying survey questions would then involve something like this (leaving out related choice records for clarity):

SELECT * FROM questions WHERE survey_id=<survey id> ORDER BY <sort field here>

...and then looping through the record set until hitting a question where page break field==true.

Method 2:

Create a page or section field in the questions table.

sort field page/section field

1             1
2             1
3             1
4             2
5             2
6             2
7             2

This allows for a simpler SELECT when querying for questions of a give page:

SELECT * FROM questions where survey_id=<survey id> AND <page field>=<page no.> ORDER BY <sort field>

Also, is it considered bad practice to rely on a sequentially numbered sort field, i.e., no gaps allowed in the sort field values? The sort field is not a key, it's just used to order the questions. Sequential numbering, of course, requires that when a question is deleted, all the questions of that survey be re-sequenced. But an advantage is that when displaying survey questions, the sort field value can be used as the question number displayed to the end user, as opposed to using a counter or something. Also, each answer choice record (questions 1-to-many choices) has a "skip to question number" field into which the user enters a question order number (ex: 3 for 3rd question of survey), but the app stores the question id, so reordering doesn't mess this up. Without sequential order field values, translating from question id to question number when displaying "skip to question number" values to a survey editor user is a bit of a pain.

Andrew

awarner_20007 yahoo com Received on Fri May 16 2003 - 19:48:49 CEST

Original text of this message