Re: Stroring html form settings - Mailing list pgsql-general

From Jeff Soules
Subject Re: Stroring html form settings
Date
Msg-id c956da920809251727o58c0b319qdff336bb9df02cd@mail.gmail.com
Whole thread Raw
In response to Stroring html form settings  (Dianne Yumul <dianne@wellsgaming.com>)
Responses Re: Stroring html form settings
List pgsql-general
On Thu, Sep 25, 2008 at 5:38 PM, Dianne Yumul <dianne@wellsgaming.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

pgsql-general by date:

Previous
From: Frederik Ramm
Date:
Subject: Re: Various intermittent bugs/instability - how to debug?
Next
From: Martin Gainty
Date:
Subject: Re: Stroring html form settings