Im building a micro CMS. Using Mysql as RDMS, and Doctrine ORM for mapping.
I would like to have two types of pages. Static Page, and Blog Page. Static page would have page_url, and page_content stored in database. Blog page would have page_url, but no page_content. Blog would have Posts, Categories…
Lets say I have route like this:
/{pageurl}
This is page, with page url that can be home, or news, or blog… That page can be either Static page, and then I would joust print page_content. But it can also be Blog Page, and then I would print latest posts as content.
How should I relate these Static Page and Blog Page tables? Is this inheritance, since both are pages, with their URL, but they have different content? Should I use inheritance, so that both Static and Blog page extends Page that would have page_url? Or should I made another table page_types and there store information about available page types?
Best Answer
I would recommend that you have a Pages table that contains both Static, Blog and any new pages you may have. The Pages table would have the columns page_url, page_content and pagetype (a tiny integer) which will help you differentiate between different pages. Later u may end up with other page types which have content hence leaving page content as a field in the pages table and may also allow you to have custom PHP or markup content in a blog page for customization (thinking aloud)
You can then have a BlogPages table which has the information for blog pages linking to the categories and posts.