views:

52

answers:

1

Hi,

I'm writing a CMS in PHP that allows the user to define different fields (e.g. a Blog page could have fields for Title (string), Content (rich text), Picture (file)). I need the user to be able to add and remove fields dynamically, and the only way I can think of to do it with relational DBs is to serialise all these values and store them in one cell.

This seems like a slow approach and like I'm trying to fit something dynamic within a static structure. Could someone recommend anything that is PHP-compatible that would make this easier?

+4  A: 

One answer is document-oriented databases such as CouchDB.

Another answer is not to have a pre-defined database, but create it dynamically in response to user's wishes.

Third possibility, within a relational database, is to have a table that looks like (id, name, value), so that a n-column row would be written as n rows in this table. It's not too pretty though. It is easy enough to find any specific value then, but if you want them all you will want a n-fold custom-built join :)

Amadan