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:
- Should the position field be within the page table or page_version table? The position for each page will not change depending on the version of the page. This will only be changed in the list view of all pages. This is so that if you have for example,5 child pages of the 'About Us' page, these can be ordered for rendering the output on the front end.
- Should the rewrite_rules table join the page table or page_version table? Again, this will be linked to a page rather than the version. If someone edits a version of a page and adds a rewrite rule, this will be applied to the page, not just that version of the page. I.e if you were to revert back to an older version, the rewrite rule would still apply to this version.
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;
}