2023-05-10 03:21:29 +04:00
|
|
|
-- SQLite3
|
|
|
|
CREATE TABLE IF NOT EXISTS `category` (
|
|
|
|
`category_id` INTEGER NOT NULL,
|
|
|
|
`name` TEXT NOT NULL,
|
|
|
|
PRIMARY KEY (`category_id`),
|
2023-05-19 21:53:44 +04:00
|
|
|
UNIQUE (`name`) );
|
2023-05-10 03:21:29 +04:00
|
|
|
|
2023-05-20 06:27:45 +04:00
|
|
|
INSERT OR IGNORE INTO `category`
|
2023-05-10 03:21:29 +04:00
|
|
|
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
|
2023-05-19 21:53:44 +04:00
|
|
|
ON UPDATE CASCADE );
|