Sunday, February 19, 2012

Why dont you create your own CMS???--Part 3

Lets create our database tables.


Before writing class file let us create tables on our 'stupid' database.
Haven't created the database!!!!!!!
Please create one with name 'stupid'.
We will have 2 tables in our database.One for storing the settings of our site and the other for storing modules data.Are you confused??
Don't worry I will provide the sql for you.
The sql for settings table is as follows:
====================================================================

CREATE TABLE IF NOT EXISTS `settings` (
  `sitename` varchar(60) NOT NULL DEFAULT 'My new CMS',
  `admin_username` varchar(40) NOT NULL DEFAULT 'admin',
  `admin_pass` varchar(40) NOT NULL DEFAULT 'admin',
  `theme` varchar(50) NOT NULL DEFAULT 'default'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

======================================================================
The field sitename stores the name of the CMS,field theme stores the name of the current active theme (default by default).
The other two fileds stores the
Now let us create modules table.
=====================================================================

CREATE TABLE IF NOT EXISTS `modules` (
            `m_id` int(11) NOT NULL AUTO_INCREMENT,
            `name` varchar(256) NOT NULL,
            `active` tinyint(1) NOT NULL DEFAULT '0',
            PRIMARY KEY (`m_id`)
          ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

=====================================================================
The field name stores the module name,active field indicates whether the module is active.A module is active if field value od active is 1,inactive if the value is 0.
As I have already told you,we will be considering homepage and admin interface as modules.So their attributes have to be stored in modules table.
Note that they should be active.
===============================================================

INSERT INTO `modules` (`m_id`, `name`, `active`) VALUES
           (1, 'admin', 1),
           (2, 'home', 1);
=============================================================
For settings table

==============================================================
INSERT INTO `settings` (`sitename`, `admin_username`, `admin_pass`, `theme`) VALUES
('My new CMS', 'admin', 'admin', 'default');
==============================================================
In the upcoming posts we will create our essential classes required for our CMS.

3 comments:

  1. how do you 'create a database'?

    ReplyDelete
  2. you can use mysql command CREATE DATABASE stupid

    or you can use gui like phpmyadmin...

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete