HomePHP Building a Relational Content Management System in PHP/MySQL
Building a Relational Content Management System in PHP/MySQL
You may be familiar with relational databases, but what is a relational content management system? Read on to learn how to build this system, which helps you create a search engine friendly site fairly quickly.
This article will show you how to build a simple relational content management system. What is a relational CMS you ask? Well, a relational CMS lets you create articles that have child articles.
This works similiar to other CMSes which have categories and then articles; we will just combine them together to be more relational.
This also helps to create a nice search engine friendly site quickly.
To keep this article easy to follow, I'll keep the relational CMS simple, but you can change it quite easily to add more stuff to it.
The Database
Our first step is to build the database. This is a pretty basic database designed for the articles. We'll need one table for this.
CREATE TABLE articles ( id BIGINT( 24 ) NOT NULL AUTO_INCREMENT , title VARCHAR( 150 ) NOT NULL , summary TEXT NOT NULL , body TEXT NOT NULL , parent BIGINT( 24 ) NOT NULL , seoname VARCHAR( 150 ) NOT NULL , PRIMARY KEY ( id ), KEY title(title), KEY seoname(seoname), KEY parent(parent) ); INSERT INTO articles SET id='1',title='first page',seoname='firstpage';
You may notice that we also created the first article. We need to have an initial article for the system. You'll also see later that, while you can edit this article all you want, you can't delete it; it is the first page.