mp> I'd go for a denormalized database:
mp> (...)

tz> I'm aware of this solution, in fact I was using it. Unfortunately I
tz> had problems with deleting objects with this circular dependency, but
tz> maybe I was overlooking something (db we're using is MySQL 5).

You're right. You have to make sure to either disable foreign key checks
prior to deleting anything, which is kinda hacky, or make sure to set
the latest_revision to None prior to deleting a revision.

If that circular reference is problematic in your use case you could
also just add a boolean field to your Revision:

class FooRevision(models.Model):
    foo = models.ForeignKey()
    is_latest = models.BooleanField()
    ...

FooRevision.objects.filter(is_latest=True).select_related() will return
all latest revisions together with their base then.

tz> Anyway, my case is much more complicated so I would have to
tz> denormalize more than just one model. Because of that, of because
tz> VIEWs + fake models are quick enough for what I'm doing (and has
> enough speed reserve for the future), I decided to go this path.

Ok. I guess you'll have to stick to some custom SQL then.


--mp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to