The Locomotive book promotes the notion of Single Table Inheritance, in part because of efficiency considerations: We''re trading the purity of the customer model for speed (selecting just from the people table is much faster than fetching from a join of people and customers tables) and for ease of implementation. -- DHH (Locomotive, p. 256) A friend of mine is an RDBMS wonk. He contends that joins aren''t all that expensive (in a decent RDBMS implementation) and that putting an entire "isa" hierarchy in a single table isn''t a great idea. Efficiency considerations aside, does Rails have problems supporting the mapping of joined tables (etc) to objects? Clues solicited... -r -- email: rdm-go8te9J4rpw@public.gmane.org; phone: +1 650-873-7841 http://www.cfcl.com - Canta Forda Computer Laboratory http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc.
rails supports all relational types be default and very well. look at has_many / has_one / belongs_to / has_and_belongs_to_many On 9/17/05, Rich Morin <rdm-go8te9J4rpw@public.gmane.org> wrote:> The Locomotive book promotes the notion of Single Table Inheritance, > in part because of efficiency considerations: > > We''re trading the purity of the customer model for speed > (selecting just from the people table is much faster than > fetching from a join of people and customers tables) and > for ease of implementation. > > -- DHH (Locomotive, p. 256) > > A friend of mine is an RDBMS wonk. He contends that joins aren''t all > that expensive (in a decent RDBMS implementation) and that putting an > entire "isa" hierarchy in a single table isn''t a great idea. > > Efficiency considerations aside, does Rails have problems supporting > the mapping of joined tables (etc) to objects? Clues solicited... > > -r > -- > email: rdm-go8te9J4rpw@public.gmane.org; phone: +1 650-873-7841 > http://www.cfcl.com - Canta Forda Computer Laboratory > http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Zachery Hostens <zacheryph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
At 3:13 AM -0400 9/17/05, Zachery Hostens wrote:>rails supports all relational types be default and very well. > >look at > >has_many / has_one / belongs_to / has_and_belongs_to_manyI don''t believe that any of these has anything to do with table inheritance. -r -- email: rdm-go8te9J4rpw@public.gmane.org; phone: +1 650-873-7841 http://www.cfcl.com - Canta Forda Computer Laboratory http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc.
On Fri, Sep 16, 2005 at 10:11:27PM -0700, Rich Morin wrote:> A friend of mine is an RDBMS wonk. He contends that joins aren''t all > that expensive (in a decent RDBMS implementation) and that putting an > entire "isa" hierarchy in a single table isn''t a great idea. > > Efficiency considerations aside, does Rails have problems supporting > the mapping of joined tables (etc) to objects? Clues solicited...If you have your models in an inheritance hierarchy where the attributes for each subclass are stored in their own tables, ActiveRecord will not join on the tables defining the superclasses when you ask for an instance of a subclass. But, if your database supports it, you could accomplish this with views. For instance, in postgres, you can define views that join on the several tables in your hierarchy and also rules to permit inserting, updating, &c. You can then use set_table_name in your models to connect them to your views, avoiding STI in AR altogether. Erik. -- Reality Engine Cooperative Group Ltd Toll free 866.330.9433 Technologies that liberate. London area 519.432.8370