Älphä Blüë wrote: > I've started looking into the uses of HABTM with linked tables.
By "linked tables", you mean DB tables associated by means of foreign keys, right? > My > greatest problem right now is visualizing and connecting some of my > tables together with one another. Database design principles are practically the same for Rails apps as for any other application. > Let me provide a brief example: > > Again, using football mechanics for emphasis: > > Five groupings: > > Offense, Defense, Special Teams, Other, and Ratings What do you mean by "groupings"? > > Offense group contains 13 tables > Defense group contains 13 tables > Special Teams group contains 5 tables > Other group contains 5 tables > Ratings group contains 1 table And these tables are...? > > Total Number of Tables: 37 That seems excessive, but since I don't know your data, I can't say for sure. > > Each table houses 120 teams > Each table has the exact same team names Aha! Then there's your first candidate for normalization. Create a "teams" table, containing ID, name, and whatever else is necessary, and refer to the teams in the other tables by team_id. > > What things I know I will be doing with the data? > > I will be showcasing "individual teams" and providing a layout of all > their data for all 37 tables. Then you probably want a Team model, which will fit in nicely with what I suggested above. > > I will be running cross-comparisons of one team's data with another > team's opposing data. > Ditto. > My Question: > > Should I use HABTM and linked tables with my project in this particular > instance? You should use associations on the Rails side and foreign keys in the DB. (There's not a project I can think of where that's inappropriate, provided that the project uses a DB!) > If so, what advice can you give me on possible pitfalls and > expectations down the road? Use the foreign_key_migrations plugin to set up foreign key constraints in your DB. If you're using mySQL, use InnoDB tables so the constraints work; better yet, use PostgreSQL instead. Get familiar with DB table joins if you're not already. Get used to making one query with a huge resultset, not many queries with tiny resultsets. Good luck! Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

