Reputation: 11293
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.
Upvotes: 0
Views: 141
Reputation: 3480
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'
Upvotes: 2