Storing user specific settings


#1

I need to store user specific settings in database.
Which is a better approach

storing them in one row with each column for each setting
Table columns in these case would be
id, user_id, setting 1, setting 2, setting 3 etc

or

storing them in many rows , with setting name and value in each row
Table columns in these case would be
id, user_id, setting_name, setting_value

Regards,
Pankaj


#2

It depends.

Are they complex? Are they going to change? Is it just a bunch of
“name => value” pairs?

If it’s something simple, without complex values, you can just have a
string column with a Hash serialized to YAML.

Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)


#3

thanks Maurício,
currently all of them are binary fields about 14 of them.
More may get added later.

On Feb 14, 12:16 am, Maurício Linhares removed_email_address@domain.invalid