From: Kaspar Schiess Date: 2004-04-16T06:49:49+09:00 Subject: Re: dbi: parent / child relationship -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Vudmaska wrote: | I've got a few situations where i'm selecting a parent child | relationship with a join. I'm looking for an elegant way of iterating | through the children. Using the join, the parent table data is redundant | when there are muliple children. If I get you right there, you are talking of a specialisation/generalisation relationship here. Lafcadio has a nice way of handling that (lafcadio=another db abstraction layer): Inheritance in ~ Ruby. You'd have a class 'User' for example with the attribute #login, and then you would define a class 'Customer' to be class Customer < User ... end Based on the table contents of the users table, you would get content from both tables. Actually you'd have Customer Objects that have their content from two (or more) locations. Your loop becomes customers = objectStore.getAll Customer customers.each do |customer| ~ # access customer attributes as attributes of instance customer end assuming you want 'em all. No more sql. And I find lafcadio to be reasonably fast for most of my applications. Hoping that I am not completely missing the point of your post.. kaspar - code philosopher - -- stolen off the net -- "I have been listening," said Arthur, "but I'm not sure it's helped." ~ Ford grasped him by the lapels of his dressing gown and spoke to him ~ as slowly and distinctly and patiently as if he were somebody from a ~ telephone company accounts department. -- Douglas Adams -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFAfwQNFifl4CA0ImQRAuz6AJ0QtMP7lXnPh/YNyZGFGtFzN8H75wCfeDKi SQ1lHAAHO1aG0hAvwIXNbyI= =EUgV -----END PGP SIGNATURE-----