There is an underlying sentiment these days that every action you take must be in the correct pattern or you are doing things wrong.
If I wanted to perform an OOP join, I am a big fan of Reactor for ColdFusion that allows me to map the links between tables and call iterator objects. Now, the opposite side is that you are potentially affecting many records at once and thus this a gateway and not DAO tendency. I would choose the parent gateway and put the query/proc there and just reference it from your service. If it is academic that you seek, I can understand that, but for an implementation where you just need multiple records returned then simplicity may win through. Teddy On 12/6/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > > Teddy, > > It sounds like you are suggesting that I create a query or stored > proceedure that does an INNER JOIN on the products and productitems > table, is that correct? > > Also, should I place the method in the product gateway or the > productitems gateway? > > What are some best practices for working with 1-to-many and > many-to-many relationships between tables in the database? I looked at > the Observer pattern for working with such relationships between > objects (in the book, Head First Design Patterns), but couldn't figure > out how to apply it to tables. > > -Aaron > > On 12/5/06, Teddy Payne <[EMAIL PROTECTED]> wrote: > > Or you can just create one method in your gateway object to execute a > query > > or stored procedure and your are done. > > > > Teddy > > > > On 12/5/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > > > > > > I am getting a better grasp on this OOP stuff everyday (but it is > > > taking a while) and now I am at the point where I can't figure out how > > > to interact with 1-to-many and many-to-many relationships. > > > > > > Example: > > > I have two tables (product & productitems). The productitems table > > > contains a foreign key field so there is one product to many product > > > items. > > > > > > I need to loop through the productitems where the foreign key matches > > > the productid in the product table. Do I create an method in my > > > gateway with an INNER JOIN query. If so, would that go in the product > > > gateway or the productitems gateway? > > > > > > Also, I am using services to further abstract things. So would I > > > create a new service component to get at the method in my gateway or > > > would I add a method in one of my existing services. > > > > > > Maybe I am completely wrong and all I need to do is add a couple > > > getters and setters in my products bean. I really don't have a clue... > > > > > > Any help would be appreciated! > > > > > > -Aaron > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create robust enterprise, web RIAs. Upgrade & integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263007 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

