Hi Pádraic,

Thanks for mentioning the URL, it's very interesting! Still I have some
questions left.

As an example lets say I want to list 50 users. Every user has several
linked fields in another table, like department, company, etc. If doing this
the aggregated way, you will end up having it least 150 queries, while this
can be done using 1 (!) query with a few joins.
Here's a quote from the URL you gave: "Database operations are expensive,
often the most expensive operation"
So with this in mind, its hard for me to use the 150+ queries solution,
although I see some big advantages. I know you can cache, but still...

Isn't there some 'in between' solution?

Regards,

Koen


2009/8/21 Pádraic Brady <[email protected]>

> Hi Koen,
>
> I just published a chapter on implementing the Model you may want to look
> into to see how it fits. The book is free to read ;).
>
> http://www.survivethedeepend.com/zendframeworkbook/en/1.0/implementing.the.domain.model.entries.and.authors
>
> I think the main point I think is that you are thinking in terms of the
> database. Why use a join? You can use two distinct SQL queries and then
> aggregate these as objects. In the book, I used a simple example of blog
> entries needing authors - so the entry object contains an author object.
>
> Joins are great, no mistake, but they are also premature optimisation. You
> can offset the cost of two queries using caching and lazy loading to avoid
> database access in the first place.
>
> Hope this helps!
>
> Pádraic Brady
>
> http://blog.astrumfutura.com
> http://www.survivethedeepend.com
> OpenID Europe Foundation Irish Representative<http://www.openideurope.eu/>
>
>
> ------------------------------
> *From:* Koen <[email protected]>
> *To:* [email protected]
> *Sent:* Friday, August 21, 2009 11:36:35 AM
> *Subject:* [fw-general] Question regarding models
>
> I've been looking at the new Quick Start in the ZF manual, particularly the
> model part. For a new project I'm trying to create my models in the same way
> (including a data mapper, etc).
>
> Unfortunately I don't know how to handle the relationships. When requesting
> data from your model you often want to include some fields in related tables
> (using joins), but I don't see a way doing that using the pattern as
> described in the quick start guide. Can someone give me some tips regarding
> this?
>
> Thanks in advance!
>

Reply via email to