Simple Blog – Data Model

Simple Blog is a multi-part series. Check out The Index

Pretty simple really. Maybe too simple =)┬áHere’s the DDL to create the database objects used throughout the Simple Blog examples.

##################################################
# Create Database
##################################################
CREATE DATABASE if not exists blog;

GRANT all privileges on blog.*
	to 'blog'@'localhost'
	identified by 'secret';

##################################################
# Create Table
##################################################
USE blog;

CREATE TABLE post (
	id int not null auto_increment primary key,
	title varchar(255) not null,
	content text not null,
	created timestamp not null default current_timestamp
);

##################################################
# Sample Post
##################################################
insert into post (title, content) values ('1st Blog Post', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi.');

Continue reading