Rails Foreign key setup question.
- by James P. Wright
I'm just (re)starting playing around with Rails and I'm making a little card game app. I cannot seem to figure out my Foreign Key setups.
Say I have 4 objects:
- Game
- Player
- Hand
- Card
A Game has many Players, which have many Hands which have many Cards. But the cards are also independent of a Hand, Player and Game.
For example, I have 6 Cards in my database (1 to 6). It is possible that Card 3 could be in 2 Players Hands in the same Game.
How can I set up my keys for this? Should I just create another object for "CardInHand" to simplify it?