On Wed, Nov 17, 2010 at 8:42 AM, 肖晗 <xiaohan2...@gmail.com> wrote:

> I plan to design a small survey/poll system similar to
> polldaddy<http://polldaddy.com/>
> .
> And I have some confusion in designing the database for the multiple/single
> choice questions. Of course, it is possible to use one table to store the
> question title and  another table to store the choice item(one record for
> each choice item).
> My main concern is that whether we can place the choices together in the
> same table(and in one ) with the question title. I guess it can be faster
> to
> read from one table than reading from two table.
> And my idea is to use  a delimiter to separate the choices. And the
> handling
> of the choices are done in the php script. But what delimiter should be
> used?
> Can anyone help? Thanks!

When you denormalize like this, it's important to make sure that you don't
need to perform more complex queries on the items (sorting, max, min, etc.),
as most DB's will outperform PHP for this type of work even if it does
require one or more table relationships.

That said, when the query needs are simple enough to merit this type of
approach, I tend to JSON-encode the data (
http://php.net/manual/en/function.json-encode.php), leaving a simple
JSON-decode operation (http://www.php.net/manual/en/function.json-decode.php)
to get the queried data back into PHP form.


Nephtali:  PHP web framework that functions beautifully

Reply via email to