Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango database design choice
    text
    copied!<p>I have a table of Users who are permissioned to edit one of a collection of other tables (each which has a last_modified field to indicate the last time it was changed). I have another table that tracks each change as it is made (I have a better way to track history/versioning, but this is meant more for posting a rolling list of updates to the user)</p> <pre><code>class WhatsNew(models.Model): author = models.ForeignKey(User) model_update = models.CharField("Database Table", max_length=100) object_id = models.IntegerField("Object ID") object_name = models.CharField("Object Name", max_length=100) changed = models.TextField("Fields Updated", blank=True, null=True) pub_date = models.DateTimeField("Date/Time of Update", auto_now_add=True) </code></pre> <p>I want the user to be able to see all of the edits they have made. I would do this by querying the above table, filtering on the author. But in addition, I want the user to see a list of the edits they made grouped by id. So for instance, if user 12345 edited object 2-1, then 3-2, then 2-1 again, then 4-4, I want the user to be able to see the a list (2-1, 3-2, 4-4), the time they modified the object, and the time the object was modified by anyone.</p> <p>Should I capture all of this data in a separate table or try to query it from the WhatsNew table? I think I should capture it in a new table to avoid a possibly expensive query, but I don't want to duplicate information that is already availble in the database.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload