# Database best practice question

**URL:** <https://www.ruby-forum.com/t/database-best-practice-question/137633>\
**Category:** Rails\
**Created:** [May 14, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/database-best-practice-question/137633 "2008-05-14T22:03:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [May 14, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/database-best-practice-question/137633/1 "2008-05-14T22:03:32Z")

</div>

hi folks,

i’d like some advice about how to approach this database “problem”. i  
have a website that sells products that are customizable, and are  
organized in lists. i can’t give the details of the actual product, but  
i’ll offer this baby clothes analogy:

happy hat™ beanie: fuzzy ball =\> true, pattern =\> striped, color =\>  
[blue, white]  
angry feet™ shoes: color =\> white, laces =\> fat  
pretty okay™ shirt: material =\> lead

the clothes are customized and saved in “outfits” created by users. my  
question is:

should i create database tables for each user-created outfit? that seems  
like it would get out of hand. is there a better way?

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [May 15, 2008, 5:25am UTC](https://www.ruby-forum.com/t/database-best-practice-question/137633/2 "2008-05-15T05:25:33Z")

</div>

I’d look at a table for your base products and one for accessories  
the accessories will belong to products and products will have many  
accessories

There are many , many ways to do this so i would recommend that you  
commit the time to get things laid out first, maybe sketch out a  
couple ERD’s (entity relationship diagrams ) grab some refreshment and  
some friends and explain you concepts and how you plan to extract  
input the data into/from these entity’s questions, situations you may  
have not included should come to light and now is the time to include  
them in your app

These are excellent ref material links

[http://www.softwaredeveloper.com/features/intro-to-ruby-on-rails-042507/](http://www.softwaredeveloper.com/features/intro-to-ruby-on-rails-042507/)  
[http://railscasts.com/episodes;archive](http://railscasts.com/episodes;archive)

On May 14, 4:03 pm, browner than u [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [May 16, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/database-best-practice-question/137633/3 "2008-05-16T16:19:24Z")

</div>

how long do the outfits need to be retained? do they need to be saved  
only until the user places an order/ reorders the product? are you  
planning to save the outfits for reporting?

On May 14, 1:03 pm, browner than u [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [May 16, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/database-best-practice-question/137633/4 "2008-05-16T21:17:01Z")

</div>

thanks for the reply guys. the outfits would be retained for long  
periods of time (~6 months or so).

lvizon wrote:

> how long do the outfits need to be retained? do they need to be saved  
> only until the user places an order/ reorders the product? are you  
> planning to save the outfits for reporting?
> 
> On May 14, 1:03ï¿½pm, browner than u [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
