Re: Stroring html form settings

From: "Jeff Soules" <soules(at)gmail(dot)com>
To:
Cc: "PostgreSQL List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Stroring html form settings
Date: 2008-09-26 00:27:19
Message-ID: c956da920809251727o58c0b319qdff336bb9df02cd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 25, 2008 at 5:38 PM, Dianne Yumul <dianne(at)wellsgaming(dot)com> wrote:
> Hello,
>
> I have some html forms that I save the settings into the database, things
> like which item was selected in the menu and if a checkbox was checked. The
> table looks like this:
>
> user_id | report_id | info
> ---------+-----------+------------------------------------------------
> 111 | 1 | A:::::CHECKED::::CHECKED::::CHECKED::
> 111 | 2 | A:::CHECKED::
> 111 | 3 | A::CHECKED:CHECKED::CHECKED::::CHECKED:::
>
> The info column has the settings separated with a : and consecutive colons
> mean the user didn't make a selection. Would this be the way to store them?
>
> I've done some searching and I could use XML (I will read some tutorials
> after writing this email). But there may be other ways and I'm just too much
> of a newbie to know. I'm using Postgresql 8.1.11 and PHP on CentOS 5.2.
>
> Thanks in advance.
>
> Dianne

Hi Dianne,

My first thought is that if you use a combined "info" field, you'll
lose the ability to easily do any kind of meaningful data analysis
based on which boxes are checked. If you just want to record what a
given user said at a certain time, but don't need it for any other,
more interesting evaluation of the data, then why bother with a
database? Also, if the form structure & options etc. are at all
subject to change, you've eliminated the possibility of doing data
integrity checks and you may wind up with a code in the "info" field
that is out of date relative to what the form looks like now, i.e. the
"info" field was filled when the values corresponded to something
different from what they mean at read-time.
An XML format might be one way to record key-value pairs, and avoid
the possibility of new interpretations of the code invalidating your
old data, but from the database perspective, actually storing XML is
space-intensive, kinda clunky, and doesn't really leverage the things
you can do with a database.

If it were me, I would probably store the form values in the database
fields, so that the table's columns matched the various data inputs in
the form. (That's if you don't expect the form structure to change a
whole lot). Then again, I'm probably the least experienced person on
this list, so I'm sure I'll be corrected shortly : )

Best,
Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Gainty 2008-09-26 00:32:19 Re: Stroring html form settings
Previous Message Frederik Ramm 2008-09-26 00:25:38 Re: Various intermittent bugs/instability - how to debug?