# Storing user specific settings

**URL:** <https://www.ruby-forum.com/t/storing-user-specific-settings/160291>\
**Category:** Rails\
**Created:** [February 13, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/storing-user-specific-settings/160291 "2009-02-13T20:13:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [February 13, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/storing-user-specific-settings/160291/1 "2009-02-13T20:13:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [February 13, 2009, 8:16pm UTC](https://www.ruby-forum.com/t/storing-user-specific-settings/160291/2 "2009-02-13T20:16:48Z")

</div>

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/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

---

<div class="post-metadata">

**Author:** ![pankaj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a9adbd/32.png) [@pankaj](https://www.ruby-forum.com/u/pankaj)\
**Post date:** [February 13, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/storing-user-specific-settings/160291/3 "2009-02-13T20:55:03Z")

</div>

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](mailto:removed_email_address@domain.invalid)
