I am creating a CMS where all pages for our website can be added/updated/deleted/re-positioned etc. I am creating a oneToMany relationship between pages and page_versions so each time a page is amended in the CMS a copy will be saved as a page_version so we can revert back to this version if needed. Also, when someone is currently editing a page, it will become locked so no other user can edit it at the same time. Each page can also have a parent page and each page can have multiple rewrite rules using another oneToMany relationship with the rewrite_rules table. However, there are a few fields which I am unsure as to what table they should be in and how they can be used as objects when mapping using Symfony2 and Doctrine entity relationships. Here are my tables at the moment:
page table
id
parent_id
locked
page_version table
page_id
title
content
enabled
position
rewrite_rules table
id
page_id
rewrite
canonical
My questions are:
To make a page version the active page, should this be a simple field in the page table or in the page_version table?
Thanks
UPDATE
Here are my Page and PageVersion classes:
class Page { /** * @ORM\OneToMany(targetEntity="PageVersion", mappedBy="page") */ private $pageversions; }
class PageVersion
{
/**
* @var page
*
* @ORM\ManyToOne(targetEntity="Page", inversedBy="pageversions")
*
*/
private $page;
}
Consider that versioning associations becomes really annoying on the long term. Also, you should probably remove OneToMany
relations and keep only the ManyToOne
side of them.
This makes it easier to version your data by using a tool like EntityAudit, which unfortunately didn't work in my case (doesn't support inheritances).
So my advice is: