As according to Martin Fowler, versioncontrol makes heavy use of the highly normalized Class Table Inheritance pattern, where each "class" (in our case, array) gets its own table and only contains fields relevant only to that class. For example, versioncontrol_operations is the supertype class, and versioncontrol_commits, versioncontrol_branch_operations and versioncontrol_tag_operations are the subclasses. In order to access all of the data for a JOIN needs to be performed; in practice two JOINs are necessary due to the fact that each repository can add its own data.

I would like to bring up for consideration the Single Table Inheritance pattern, which would abolish those subclass tables and put everything in versioncontrol_operations. Here's why:

  • The subclass tables contain very few columns, so space inefficiency would largely be a non-issue; it might even be more efficient because we remove the need for foreign keys
  • It simplifies queries by eliminating the need for a second join beyond the join we would need to link this table with the repository-specific one
  • There are duplicate columns in some of the tables, for example description is present in commits and tags

There would only be a slight denormalization; at most two columns would not be used by a datatype. Backwards compatibility can be maintained using views to emulate the older tables. Thoughts?

Comments

jpetso’s picture

Status: Postponed (maintainer needs more info) » Active

Actually, I tend to think that's a really good idea, and I'm going to include this proposal in my next round of large database changes. hunmonk likes it as well, and with a bit of table schema documentation (Drupal 6, here we come!) it shouldn't cause too much confusion, or maybe even less than the current scheme.

It can maybe even enable a single unified versioncontrol_get_operations() function that uses just one query instead of getting data from the get_commits(), get_branch_operations() and get_tag_operations() functions... let's see if that's doable too, afterwards.

jpetso’s picture

Oh right, and using Views to emulate the older tables will not happen. People should just update their modules and database schema and be done with it.

jpetso’s picture

Status: Active » Fixed

Though HEAD is currently in a non-working state, this proposal can definitely be regarded as implemented. Thanks for the suggestion, I now consider this issue *fixed*. Yay.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.