views:

51

answers:

1

In this case I am referring specifically to Google Friend Connect - Social Bar parameters. Users can select from various parameters when setting up their SocialBar i.e.

skin['BORDER_COLOR'] = '#cccccc';
skin['ENDCAP_BG_COLOR'] = '#e0ecff';
skin['ENDCAP_TEXT_COLOR'] = '#333333';
skin['ENDCAP_LINK_COLOR'] = '#0000cc';
skin['ALTERNATE_BG_COLOR'] = '#ffffff';
skin['CONTENT_BG_COLOR'] = '#ffffff';

I want to store those custom values in a MySQL table, but I don't want to create a field for each possible parameter.

I was thinking of storing it in more of a JSON type string in one field:

{"BORDER_COLOR":'#cccccc',"ENDCAP_BG_COLOR",'#e0ecff'}

Or like an .ini type file array. Am I nuts?

The reason is that I am dealing with a varied number of parameters and there may be more in the future which would mean adding another field to an existing table.

+2  A: 

It works, and would be very easy to parse the data into a class.

However, it would be pretty annoying to do updates in the database if you need to add a new parameter to all users, or if you need to change/fix a specific parameter, since you'd need to write an application, or use string-manipulation functions.

One simple alternate DB structure you could use:

TABLE PREFERENCES
(
USER int not null
KEY varchar(20)
VALUE varchar(20)
)

So one record woud be:

USER=1234
KEY='ALTERNATE_BG_COLOR'
VALUE='#ffffff'
Badaro
Yeah, I was going to suggest this, it's the way I'd do it.
codemonkey