durusmail: quixote-users: OT - zodb best practices with quixote
OT - zodb best practices with quixote
2003-01-06
2003-01-07
OT - zodb best practices with quixote
Neil Schemenauer
2003-01-07
On Tue, Jan 07, 2003 at 05:37:33PM +0100, Juan David Ib??ez Palomar wrote:
> Typically you build interfaces that show different views of
> the same data, for example, "show all the members of a group"
> (1) and "show all the groups a member belongs to" (2). In this
> example, without a query language there are three solutions:
>
> 1. The group object has a list with all the users that belong
>    to it; then the first view is simple but the second one is
>    complex.
>
> 2. The user object has a list with all the groups it belongs to;
>    then the second view is simple but the first view is complex.
>
> 3. The group has the list of users and the user has the list of
>    groups. Then both views become simple, but data is duplicated
>    and you have to keep it in sync, making changes becomes
>    complex and error prone.

If you need to do both operations often then 3 is the best solution.
Keeping the data consistent is a matter of providing an interface to
manipulate it.  That's just good programming.

Also, which do you think is faster: accessing a list attribute that is
most likely already in memory, or doing a join on tables that could have
a large number of rows?

Writing an application with ZODB is similar to writing an application
with no database.  Ask yourself what data structures you would use in
order to be efficient if the data was not persistent.  Usually it's a
small step from there to decide how and where persistent data should be
connected to the DB root.

  Neil

reply