Edgewall Software

Version 2 (modified by Christian Boos, 18 years ago) ( diff )

uplink added

Trac Data Model Proposal

Note: at this point, this is a very rough sketch, but I felt the need for a small braindump ;)

The Context

Trac store the data for its resources in various tables, each tailored to a specific situation. This leads to a similar variety of APIs in our model modules, to heterogeneous functionality for no good reason etc. All of this has been exposed since a long time, in the TracObjectModelProposal.

More recently, I outlined a way to provide more consistent change tracking and concentrate the autorship of resource modifications in one place (the journal), in TracDev/Proposals/Journaling.

The Generic Model

Resource Data

The new model should have a good balance between generality, so that the API can be the same across resources) and specificity so that the DB load is spread across multiple tables, and additional tables can be easily joined to the generic ones, depending on a module specific need (in particular, the vc layer).

Each resource type should have its own main table, for registering the identity of each object.

  • (+) each dependant table won't have to repeat the full id of a resource for linking to it
  • (+) facilitates resource renaming
  • (-) makes the raw db content less readable
  • (-) this is not a mandatory change, I think we can do with full id if this is prefered

That main table could eventually also store some mandatory fields, which are always of (1:1) cardinality.

Then, each resource should have a <resource>_prop table, which can be seen as a generalization of the ticket_custom table we have now. I think it's enough to have (name,value) columns, however, as the type information could eventually be stored in some resource_schema table.

Also, it might well be that we'll actually need to have datatype-specific property tables, like _prop_int, _prop_text, even _prop_resource for linking to other resources.

The property approach is essential for solving some of the main drawbacks of the current model:

  • overcome the 1:1 limitation of ticket → milestone, ticket → component (btw, components should also become toplevel resources)
  • deal with content in an uniform way; for example, it should be possible to access a wiki page content and a ticket description the same way.

The property tables above contain a snapshot of the current values for those objects.

Resource Change History

Every "transaction" (change to any resource in the system) is tracked in a journal table, containing an unique id for the change tid, the date of the change, the authorship information (author, ip number, authenticated flag) and the affected resource (type,id) (*).

For each property table, there will be a corresponding _history table, containing the (name, value) changed during this transaction. No more old_value, new_value pairs, this can be reconstructed from the full history of changes.

When focusing the history of a text property, we actually have access to the various versions of that content. This is how wiki page content, ticket and milestone descriptions could be versioned all the same way, and therefore accessed the same way by the API. From that, it would be trivial to build similar web UI for these, in a "cheap" way.

The comments will like wise be a simple "comment" text property, with accompanying "cnum" and "replyto" int properties. Instead of accessing that field in the same way as a page content or ticket description, each version of the field will be picked and inserted in the right place when displaying the history of change for the resource (i.e. it will look exactly the same as our current ticket UI, but we could potentially have exactly the same for Wiki pages, Milestones and Changesets).

Lastly, there would be an _overlay table for storing old versions of versioned properties themselves, should they ever change. This would be a way to enable editing ticket comments, and version 1 of commit messages, should they change in the repository itself (svn:log editing hint hint).

(*) For dealing with "batch" changes (e.g. #525), there could eventually be a specific extension to this: if the (type, id) data stored in journal is NULL, then we'd look in a batch_change table, relating the tid to (1:N) resources.

to be continued…


See also: TracDev/Proposals, #150, #221, #695, #787, #918, #1113, #1386, #1395, #1678, #1835, #2035, #2344, #2464, #2465, #2467, #2662, #2961, #3003, #3080, #3718, #3911, #4588, #5211, #7871, #8335, #9263

Note: See TracWiki for help on using the wiki.