23 lines
622 B
SQL
23 lines
622 B
SQL
-- SQLite3
|
|
CREATE TABLE IF NOT EXISTS `category` (
|
|
`category_id` INTEGER NOT NULL,
|
|
`name` TEXT NOT NULL,
|
|
PRIMARY KEY (`category_id`),
|
|
UNIQUE (`name`) );
|
|
|
|
INSERT 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,
|
|
`body` TEXT NOT NULL,
|
|
PRIMARY KEY (`post_id`),
|
|
FOREIGN KEY (`category_id`)
|
|
REFERENCES `category` (`category_id`)
|
|
ON DELETE CASCADE
|
|
ON UPDATE CASCADE ); |