Development

Building a Content Management System Pt 1 – The Data Model

Database and Tables

One of the big drivers of the Internet over the years has been the availability of software to make the publishing of content easy for everyone.

The more popular of these products are often referred to as Content Management Systems (CMS). They provide functionality beyond basic page creation including media management, publishing control and visual editing tools.

Some of these you can pay for, like Sitecore. Some are free, like WordPress which I’m using to write this now. And if you want to do something different you can even make one yourself.

I’ve been critical in the past of always assuming that one size fits all for a CMS so wanted to get some perspective on the matter and decided that during my spare time I’ll look into how to make my own.

By no means am I expecting to come up with anything substantial but I hope to at least have something that at least works well enough for me. And talk about some of my trials and tribulations along the way.

Part 1 -The Data Model

In the beginning of a software project, I believe that the single most important task is to come up with an effective definition of the data you are dealing with. Getting this right sooner rather than later will make the development process a lot easier and also help develop a long term understanding of where you can take the product in the future.

As I’m building something to generate a website, it will help to have a method of storing its structure in a hierarchical/tree form. Luckily for me the theory for my data requirements had already been done years ago.

My decision was to use the Adjacency List Model which provides the means to define a hierarchy within a single table by having each record include a field that references its “parent”. It’s simple to implement and as long as you handle edge case scenarios, such as deletions potentially creating orphan branches, it’s a good framework to begin with.

An alternative I did look into was the Nested Set Model which also uses one table but each record references its two closest neighbors, the record before and after. Though it simplified some aspects such as ordering it also required more complex code to implement, making maintenance more confusing.

In the end I found by using additional fields with my Adjacency List I was able to make up for its shortcomings and have a set of hierarchical data that was easy to work with. It’s only a single aspect to one table in my database but its implementation allows for everything else to build on a foundation that meets my needs.

Advertisements

Categories: Development, Opinion, Technology

Tagged as: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s