Thursday, 15 July 2010

Symfony2 + Doctrine Object/Database mapping -



Symfony2 + Doctrine Object/Database mapping -

i creating cms pages our website can added/updated/deleted/re-positioned etc. creating onetomany relationship between pages , page_versions each time page amended in cms re-create saved page_version can revert version if needed. also, when editing page, become locked no other user can edit @ same time. each page can have parent page , each page can have multiple rewrite rules using onetomany relationship rewrite_rules table. however, there few fields unsure table should in , how can used objects when mapping using symfony2 , doctrine entity relationships. here tables @ 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 position field within page table or page_version table? position each page not alter depending on version of page. changed in list view of pages. if have example,5 kid pages of 'about us' page, these can ordered rendering output on front end end. should rewrite_rules table bring together page table or page_version table? again, linked page rather version. if edits version of page , adds rewrite rule, applied page, not version of page. i.e if revert older version, rewrite rule still apply version.

to create page version active page, should simple field in page table or in page_version table?

thanks

update

here page , 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 versioning associations becomes annoying on long term. also, should remove onetomany relations , maintain manytoone side of them.

this makes easier version info using tool entityaudit, unfortunately didn't work in case (doesn't back upwards inheritances).

so advice is:

if it's not relevant version property, don't it. versioning complex problem, , expensive 1 too. yagni. if want track if page had rewrite rules or not in past, need version association, since rewrite rule doesn't have effects per-version, yagni. in sentiment may connect page rewrite (also here: maintain association uni-directional if possible). you need reference "active" page in "page" object. speeds queries quite bit, plus makes easier work oop api.

database symfony2 doctrine mapping entity-relationship

No comments:

Post a Comment