This repository has been archived on 2023-05-27. You can view files and clone it, but cannot push or open issues or pull requests.
site/sql/0-initdatabase.sql

29 lines
575 B
MySQL
Raw Normal View History

2022-12-23 20:58:54 +00:00
-- 22-12-22
-- Init the database
START TRANSACTION;
CREATE DATABASE [IF NOT EXISTS] site;
USE site;
CREATE TABLE post(
ID INT AUTO_INCREMENT PRIMARY KEY,
author VARCHAR(32) NOT NULL,
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
title VARCHAR(64) NOT NULL,
);
CREATE TABLE tag(
ID INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(32)
);
CREATE TABLE post_tag(
tag_id INT NOT NULL,
post_id INT NOT NULL,
FOREIGN KEY (tag_id) REFERENCES tag(ID) ON DELETE CASCADE,
FOREIGN KEY (post_id) REFERENCES post(ID) ON DELETE CASCADE
);
COMMIT;