Link to home
Start Free TrialLog in
Avatar of philwilks
philwilks

asked on

Using "text tables" to store data - good or bad?

As anyone who has looked into the inner workings of WordPress will have seen, they sometimes use text fields to store tabular data instead of creating an extra SQL table. An example of this is the "recently_edited" row in the "options" table.

For example: {a,b,c}{d,e,f} could be a three column, two row table.

My question: Is this a good or bad idea? Is there a name for this technique?

As far as I know any book on database design would always suggest moving this data into a separate table so that the information can be manipulated with an SQL query. However when you have a large database, it's often tempting to do this to cut down the number of tables and joins.

Thanks in advance for you input. Most useful response will get the points!
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

In SQL Server 2005 you can effectively do this with it's ability to store and query XML data
It's indeed a bad idea if this is data you use in your application/database and you use this method as a quick and dirty way of storing data which by nature is relational.

However, several engines offer the option to store an array in one field - InterSystems Caché and the new engine of Access in version 2007 - comes to my mind.
The reason to do this should be that the single elements of the array carry no useful information; the useful information is exactly the _collection_ of data elements.

An example could be RGB colour settings for, say, a background. Usually you create a compound value of the discrete values for R, G, and B respectively. This means that you have to perform a calculation both when storing and when retrieving a colour set to have the three values. Storing a three element array with the three values is much easier.
Of course, if you are able to store an array in an element of another array, this can be expanded, but I would say you should have very good reasons for doing so.

/gustav
ASKER CERTIFIED SOLUTION
Avatar of NovaDenizen
NovaDenizen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial