Column Comments used for data (in mysql 5)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tkg Chris
Forum Newbie
Posts: 1
Joined: Thu Feb 14, 2008 9:04 am

Column Comments used for data (in mysql 5)

Post by tkg Chris »

I know that its non-standard practice, but what are the pros/cons about using a comment on a column to contain data that is queried and used as display information in an application. This design could potentially save valuable development time as we customize our application for several clients with different needs. A thread on the mysql board asks if its possible,
Nick Weavers wrote:I was wondering if I could use table and column comments to store "metadata".
David Ashman's Response wrote:Just seems wrong to try and hack comment usage for actual data you want to use... in a database made to store data in the first place.
I would like to know if this practice should be avoided for any specific reasons (some characters not allowed or too much overhead on the db for instance) or if it is a decent approach or Should a relation table of "labels" be created to address this issue properly? (DBA's please throw your 2 cents in =D)

Basic example of usage in the application:

Code: Select all

loop of all queried col names and comments
{
     label (comment): form input (col name)
}
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Column Comments used for data (in mysql 5)

Post by Stryks »

Personally, I would be very reluctant to tackle this problem in this way. Firstly, I'm not entirely sure how to go about getting the comment data, and secondly I can see a definite relationship between the data stored and the label. Being able to see the relationship so clearly would immediately suggest to me that a workaround (see hack) was not required or recommended.

I would imagine that pulling the comment data is going to require a second (separate or nested) select, both of which would likely be less efficient than a simple join to a series of labels.

Interested to hear any other feedback though. :)
Post Reply