Welcome Guest, Not a member yet? Register   Sign In
Best solution for custom / unplanned fields in database?


I keep having the need save custom data in the database. It could be the data from different page types in a cms etc., basically forms that the users can build themselves.

What is the best way to do this?

What I've used so far is to have three tables:
Field group - groups a set of field intos a complete form
Field settings - defines the field names, rules, type etc.
Field data - holds the data submitted for the fields

The Field data table would have these columns:

id (int) | page_id (int) | field_id (int) | data (text)

This has worked very well so far, but the concern is that the data column for the field data table has to have a data type in the database that would work for all types of data, so I've ended up with Text. Meaning that even if it's a field that will hold a tiny string or number, it's always the big data type Text. And I'm sure there are more flaws to this solution.

The only thing I can think of to solve this is to have a table for each "field group" and then actually modify that when adding/removing columns. But is this any good?

Messages In This Thread
Best solution for custom / unplanned fields in database? - by El Forum - 05-22-2009, 03:34 AM

Theme © iAndrew 2016 - Forum software by © MyBB