-- SQLite3
CREATE TABLE IF NOT EXISTS `category` (
    `category_id` INTEGER NOT NULL,
    `name`        TEXT NOT NULL,
    PRIMARY KEY (`category_id`),
    UNIQUE (`name`) );

INSERT OR IGNORE INTO `category`
VALUES
    (1, 'Update'),
    (2, 'Diary');

CREATE TABLE IF NOT EXISTS `post` (
    `post_id`     INTEGER NOT NULL,
    `category_id` INTEGER NOT NULL,
    `date`        INTEGER NOT NULL,
    `title`       TEXT    NOT NULL,
    `url`         TEXT    NOT NULL DEFAULT "",
    `body`        TEXT    NOT NULL,
    PRIMARY KEY (`post_id`),
    FOREIGN KEY (`category_id`)
        REFERENCES `category` (`category_id`)
        ON DELETE CASCADE
        ON UPDATE CASCADE );