Model to wrap many Active Record Models

Raymond O'connor wrote:


I'm working on a web-store app and ran into an interesting problem. I
have to maintain a very large inventory from multiple facilities. Due
to database performance concerns I've separated the inventories of each
facility into a separate table. So now I have active record models for
a bunch of tables like inventory_a and inventory_b. There are times,
however, when I still want to treat all these tables as one. For
example, for a product search I would like to be able to call
find_by_sku() and have it call that method on each inventory table

I'm currently planning on creating an inventory_all model (that does not
subclass Active Record). It would contain all the methods that I would
want to call on all the inventory tables as a whole, and I would end up
calling it’s methods when I want to access all inventory tables (ie
InventoryAll.find_by_sku). I can't help but think that there is
something I'm missing, though. Is there a better way to do this?


A database that supported partitioned tables could simplify things greatly.

Not sure if MySQL 5.1 is quite production ready yet, but that sounds like it would perfectly solve your problem at the source.