Thanks for the pointers. I've been designing databases for close to 15
years, and have been working with Rails for over 4 years. I've
certainly used HABTM and has_many :through for many projects without
issue. I already have the data constructed correctly, but I do
appreciate the hand holding effort anyway. This is a very particular
processing need. Should there be a wildly useful way to restructure
the database without over denormalizing/normalizing what I already
have, I'm open to it, but I doubt very much that's where the problem
lies.
For sake of the conversation here are some fictitious models that
match my scenario identically:
TABLES
---------------------------------------------------------------
features
id:integer
name:string
schools
id:integer
name:string
features_schools
feature_id:integer
school_id:integer
MODELS
---------------------------------------------------------------
class School < ActiveRecord::Base
has_and_belongs_to_many :features
end
class Feature < ActiveRecord::Base
has_and_belongs_to_many :schools
end
How would I pull out all the schools that have ALL of the following
fictitious features: 'Wheelchair Access', 'Playground', 'Sandbark',
'Library', 'Computer Lab', and 'Testing Center'? Note that it would be
unacceptable to return schools that do not have one of those
associations.
-Kevin
On Jul 7, 2009, at 8:18 PM, Älphä Blüë wrote:
>
> I'll give you what advice I do know. I'm not sure it will fully help
> you with your situation but it may help you to rethink your
> strategies.
>
> First, make sure your tables are normalized before assigning
> associations to them. If you are going to work with HABTM then 3NF or
> greater..
>
> The larger the query the better. Smaller queries are worse than one
> enormously large query because rails caches that query for use and
> doesn't have to go out and do another.. and another..
>
> It will be less of a problem to process the data once you have it so I
> wouldn't worry about data processing at this point. It's better to
> just
> get the design and associations going.
>
> Without seeing your models, it's more difficult to guess what may be
> right or wrong from a design point. You might want to state exactly
> how
> many models you have, what tables and relationships you currently have
> associated which will help tie into your original topic.
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---