Book Image

Sphinx Search Beginner's Guide

By : Abbas Ali
Book Image

Sphinx Search Beginner's Guide

By: Abbas Ali

Overview of this book

Table of Contents (15 chapters)
Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Time for action - creating database tables for a blog


  1. 1. Create the database by executing the following query:

    CREATE DATABASE myblog
    
  2. 2. Create the posts table:

    CREATE TABLE `myblog`.`posts` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `title` VARCHAR( 255 ) NOT NULL ,
    `content` TEXT NOT NULL ,
    `author_id` INT UNSIGNED NOT NULL ,
    `publish_date` DATETIME NOT NULL
    ) ENGINE = MYISAM;
    
  3. 3. Create the authors table:

    CREATE TABLE `myblog`.`authors` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `name` VARCHAR( 50 ) NOT NULL
    ) ENGINE = MYISAM;
    
  4. 4. Create the categories table:

    CREATE TABLE `myblog`.`categories` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `name` VARCHAR( 50 ) NOT NULL
    ) ENGINE = MYISAM;
    
  5. 5. Create the posts_categories table:

    CREATE TABLE `myblog`.`posts_categories` (
    `post_id` INT UNSIGNED NOT NULL ,
    `category_id` INT UNSIGNED NOT NULL ,
    PRIMARY KEY ( `post_id` , `category_id` )
    ) ENGINE = MYISAM;
    

What just happened?

We created a database to hold the...