Creating tables

The first and most important charecteristic for such type of a system is that the article whatever it may be must be in a database with an articleID associated with it.

So first create an table for an article like this

# Create a table for articles over here
create table articles (
  articleid int(5) primary key auto_increment,
  articlesubject varchar(255),
  articletext text
);

Once done with creating the articles table you need to create a posting table where user can post comments on the article. For that create a table as comments as follows

# Create a table for comments
create table comments (
  comid int(5) primary key auto_increment,
  articleid int(5),
  comsubject varchar(255),
  comuser varchar(255),
  comdate datetime,
  comtext text,
);

Here the articleid is the foreign key, don’t worry about foreign or home. It is just to link the comment to what article. The date time records the date, time in “YYYY-MM-DD HH:MM:SS” format.
comtext is a text field and can store big text values.

Now once you have created the table for article, it is time to fill some values into them let us fill some easy values into it.

> insert into articles(articletext) values ('This is some easy article and is for some testing purpose only');
> insert into articles(articletext) values ('This is another easy article and is for some testing purpose only and not to be fiddled with'); 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.