Adam Setzler
2006-Feb-13 07:01 UTC
[Rails] Table Relationships and ActiveRecord Associations
First of all, I love Ruby on Rails. I have an intermediate understanding of PHP, JavaScript, DOM and CSS, and that''s the extent of my programming experience. I''m developing an online game''s web presence with another colleague. We''re the only two technical guys on a team of +10 content developers. So, baring all that in mind, here are my questions with a bit of background information: We have a table for characters. They can have items (weapons, armor, etc), skills, spells and other things, like languages. They each have a class and race. My question is about how to set up the different relationships between these tables. Are there any good, in depth tutorials (with extensive examples) on how to set up relationships between tables? For instance, I know that the relationship between a character and its class would be: belongs_to, has_many But how would I set up the relationship between characters and other items? If a character has multiple "skills," how should I set up the other tables? Would I use an "in between" table? Would it be easier to serialize the information? If so, how does that work? I''m not terribly concerned about portability. We use DreamHost as our host, who is wonderful enough to support Ruby, and we plan to stay with them. I apologize for the gruesomely newbish form of this inquiry, but I would love to further the use of Ruby on the Web. Sincerely, Adam -- Posted via http://www.ruby-forum.com/.
Anthony Green
2006-Feb-13 13:03 UTC
[Rails] Re: Table Relationships and ActiveRecord Associations
> Are there any good, in depth tutorials (with extensive examples) on how > to set up relationships between tables? > > For instance, I know that the relationship between a character and its > class would be: > > belongs_to, has_many > > But how would I set up the relationship between characters and other > items? If a character has multiple "skills," how should I set up the > other tables? Would I use an "in between" table? Would it be easier to > serialize the information? If so, how does that work?I''d suggest starting with by Googling about database normalisation techniques. What you''re describing isn''t essentionally a RoR issue. Then purchase a copy of the Pragmatic Programers book and learn how Active Record interacts with DB tables. Finally expect to be doing a fair bit of Googling/posting on why things don''t work. I spend yesterday afteroon wondering why my HABTM relationships weren''t being created only to find there a bug where a model with >1 HABTM relationships . Its documented and theres a fix but I had to search the postings for the answer. Tony -- Posted via http://www.ruby-forum.com/.
Andrew Otwell
2006-Feb-13 22:34 UTC
[Rails] Re: Table Relationships and ActiveRecord Associations
On Monday, February 13, 2006, at 2:03 PM, Anthony Green wrote:> >> Are there any good, in depth tutorials (with extensive examples) on how >> to set up relationships between tables? >>>I''d suggest starting with by Googling about database normalisation >techniques. >What you''re describing isn''t essentionally a RoR issue.Right. You sound like you need a book about database design in general. You can pick up a bit about about databases from reading Rails tutorials, but it''s not the whole story. I suggest the book "Database Design for Mere Mortals" which is actually a pretty easy read and will introduce you to planning your databases, normalization, joins, and all that fun stuff. -- Posted with http://DevLists.com. Sign up and save your time!
Jim Nicholson
2006-Feb-14 03:59 UTC
[Rails] Re: Table Relationships and ActiveRecord Associations
Andrew Otwell wrote:> On Monday, February 13, 2006, at 2:03 PM, Anthony Green wrote: >> >>> Are there any good, in depth tutorials (with extensive examples) on how >>> to set up relationships between tables? >>> > >>I''d suggest starting with by Googling about database normalisation >>techniques. >>What you''re describing isn''t essentionally a RoR issue. > > Right. You sound like you need a book about database design in general. > You can pick up a bit about about databases from reading Rails > tutorials, but it''s not the whole story. I suggest the book "Database > Design for Mere Mortals" which is actually a pretty easy read and will > introduce you to planning your databases, normalization, joins, and all > that fun stuff.It may sound strange, but O''Reilly published a book on Microsoft Access (of all things) a while ago, and it contained a fairly concise, approachable, and detailed treatment of normalization. Since it''s a bit dated, you might find a copy for a good price; the chapters on Access may not be current, but the database theory sections are still very useful. =Jim -- Posted via http://www.ruby-forum.com/.
Maybe Matching Threads
- RMA question
- How often should an encrypted session be rekeyed?
- wav/raw normalization
- one day AD use -> samba-tool dbcheck reports "Normalisation error for attribute 'objectClass'"
- Continuous Normalisation error for attribute whenCreated when performing dbcheck