I'm designing the data model for a project where users can create documents, save revisions of that document that can be reverted to, and publish documents. The basic data model I have right now is something like this:
Documents
---------
id: integer PK
currentRevisionId: integer FK references DocumentRevisions(id)
publishedRevisionId: integer FK references DocumentRevisions(id)
DocumentRevisions
-----------------
id: integer PK
documentId: integer FK references Documents(id)
documentBody: text
I need to know what the published and current revisions are for a document, but I also need to know what document a revision refers to. I'm not sure how to model this without creating this circular reference.