Difference between revisions of "DesignPatternStep1"

From mi-linux
Jump to navigationJump to search
Line 1: Line 1:
 
[[Main Page]] >> [[6CC001|Advanced Web Technologies]] >> [[6CC001 - Workbook|Workbook]] >> [[6CC001 Workshop - week 04|Week 04]] >> Step 1 - Create and populate database
 
[[Main Page]] >> [[6CC001|Advanced Web Technologies]] >> [[6CC001 - Workbook|Workbook]] >> [[6CC001 Workshop - week 04|Week 04]] >> Step 1 - Create and populate database
 +
 +
== Step 1 - Create and populate database ==
 +
 +
First, let’s create a very simple table to store our blog messages.
 +
 +
The following SQL code will create the table and populate it with a couple of dummy records. Simply paste it and run it in [https://mi-linux.wlv.ac.uk/phpmyadmin/ phpmyadmin].
 +
 +
<pre>
 +
CREATE TABLE IF NOT EXISTS `messages` (
 +
  `id` int(11) NOT NULL auto_increment,
 +
  `title` varchar(255) NOT NULL,
 +
  `message` text NOT NULL,
 +
  `date_added` datetime NOT NULL,
 +
  PRIMARY KEY  (`id`)
 +
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
 +
 +
INSERT INTO `messages` (`id`, `title`, `message`, `date_added`) VALUES
 +
(1, 'Test 1', 'Hello world!', '2009-07-27 15:06:29'),
 +
(2, 'Test 2', 'Hiya', '2009-07-27 15:06:38');
 +
</pre>

Revision as of 15:42, 12 July 2011

Main Page >> Advanced Web Technologies >> Workbook >> Week 04 >> Step 1 - Create and populate database

Step 1 - Create and populate database

First, let’s create a very simple table to store our blog messages.

The following SQL code will create the table and populate it with a couple of dummy records. Simply paste it and run it in phpmyadmin.

CREATE TABLE IF NOT EXISTS `messages` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `message` text NOT NULL,
  `date_added` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;

INSERT INTO `messages` (`id`, `title`, `message`, `date_added`) VALUES
(1, 'Test 1', 'Hello world!', '2009-07-27 15:06:29'),
(2, 'Test 2', 'Hiya', '2009-07-27 15:06:38');