Hi again,

thanks a lot for your answers.
So it looks like developing for GAE is quite a different paradigm...
>From your answers i understand that:

1. I should precompute and store all aggregated data I might need
2. Changes to my database are NOT immediate (hence I can't expect accuracy)

I will consider this from now on.

Thanks again!


On Thu, Jan 7, 2010 at 8:25 PM, Satoshi <[email protected]> wrote:

> I'd add "reference_count" property (IntegerProperty(default=0)) to
> Photo entity, and increment it each time a reference happens. Then,
> call Photo.all().order("-reference_count").fetch(100) to get the top
> 100 most referenced photos.
>
> A few additional notes:
> 1. If you need an accurate reference count number, you need to put the
> routine (which reads the Photo entity, increment the reference count,
> and put it back to the database) into a transaction, but it is
> relatively expensive. I usually don't put it in a transaction unless I
> absolutely need an accurate number.
> 2. Making too many put() calls in one HTTP request is not a good idea.
> I'd suggest to perform non critical operations (such as incrementing
> reference count) asynchronously using Task Queue.
>
> Satoshi
>
> On Jan 6, 4:15 pm, Daniel Aguilar <[email protected]> wrote:
> > Hi Satoshi,
> >
> > thanks for your reply, it really helped.
> > In fact I just read this artile:
> http://code.google.com/appengine/articles/modeling.html
> > and have started implementing based on it.
> > Still wondering a couple of things, though...
> > for instance, in my app I have another class called Collage.
> > A collage entity has properties like name, date_created, etc... but also
> > layer_0, layer_1 and layer_2, which are references to Photo entities.
> > What kind of query could i perform in order to get the most referenced
> > Photos?
> >
> > Thanks again!
> >
> > need to keep track of how many times
> >
> >
> >
> > On Thu, Jan 7, 2010 at 12:51 AM, Satoshi <[email protected]>
> wrote:
> > > First of all, please remember that GAE/database is an Object-database,
> > > not a Relational-database. You can design your database with
> > > relations, but you will likely hit a roadblock later if you heavily
> > > rely on relations (because of the lack of JOIN and the performance
> > > problem of nested queries).
> >
> > > If I were you, I would simply create two models (Artist and Photo),
> > > and have the "artist" property on Photo class, which is just a
> > > reference to an Artist entity (ReferenceProperty).  If you want to
> > > show all the Photos done by a particular Artist, you just need to
> > > query it (Photos.all().filter('artist', ...)).
> >
> > > Alternatively, you could specify the Artist entity as the parent
> > > entity of each Photo, which essentially creates an entity group for
> > > each Artist - which has pros (transactions) and cons (possible
> > > performance hit because of transactions).
> >
> > > Third alternative is ListProperty, but this is difficult to do it
> > > right without putting them in an entity group (which is alternative
> > > two)...
> >
> > > Satoshi
> >
> > > On Jan 5, 9:52 am, Daniel A <[email protected]> wrote:
> > > > Hi there,
> >
> > > > I just started writting my first app after reading some documentation
> > > > and tutorials.
> > > > Looks like an exciting platform to develop on, but there're many
> > > > things I still have doubts about.
> > > > I used to develop in PHP/MySQL, and I quite don't get how should I
> > > > proceed in order to get an efficient relational model.
> >
> > > > To simplify things, I have two kind of entities: Artist and Photo. I
> > > > need to define relations one-to-many between instances of these two
> > > > entities. That is, an Artist can have many Photos, and a Photo can
> > > > only have one Artist.
> >
> > > > In my table-shaped mind, I would model three kinds of entities
> > > > (Artist, Photo, ArtistPhotoRelation). Would this approach be the
> right
> > > > thing in GAE/datastore? Maybe I should avoid the relational entity,
> > > > and use multiple-valued properties in the Artist instead?
> >
> > > > Thanks a lot!
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google App Engine" group.
> > > To post to this group, send email to [email protected]
> .
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-appengine%[email protected]><google-appengine%2Bunsubscrib
> [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Reply via email to