# Need input on DB/table design

**URL:** <https://www.ruby-forum.com/t/need-input-on-db-table-design/125368>\
**Category:** Rails\
**Created:** [January 8, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/need-input-on-db-table-design/125368 "2008-01-08T17:28:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [January 8, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/need-input-on-db-table-design/125368/1 "2008-01-08T17:28:47Z")

</div>

I’m building a site… Dah!! and it requires different skills for  
different jobs in different states. the site will start off in only  
one state but I want to make sure I’m ready for many states. I’m  
thinking of a generic skills table with columns skill1 … skillN.  
then another table with columns state, job type, skill name, skill  
column mapping to the column in the skills table. I would dynamicly  
build the table to select the skills based on state job type. I’m  
doing this one because I don;t know what all the skills are yet. and  
I’m sure I will have to add some along the way either to the state I  
start in or when adding new states. and I don;t want to have to hard  
code each state.

My question is… Is this a bad idea!! is there a better way of doing  
it?

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [January 8, 2008, 7:27pm UTC](https://www.ruby-forum.com/t/need-input-on-db-table-design/125368/2 "2008-01-08T19:27:33Z")

</div>

spokra wrote:

> I’m building a site… Dah!! and it requires different skills for  
> different jobs in different states. the site will start off in only  
> one state but I want to make sure I’m ready for many states. I’m  
> thinking of a generic skills table with columns skill1 … skillN.  
> then another table with columns state, job type, skill name, skill  
> column mapping to the column in the skills table.  
> :  
> :
> 
> My question is… Is this a bad idea!! is there a better way of doing  
> it?

Looks like this would do it

table states  
columns: id and description, etc

table skills  
columns: id and description, etc

table state\_skills  
columns: state\_id, skill\_id

Then link them up with something like

states model  
:has\_and\_belongs\_to\_many :skills

skill model  
:has\_and\_belongs\_to\_many :states

Stephan
