Tyler Perkins
b621ced611
All checks were successful
continuous-integration/drone/push Build is passing
29 lines
575 B
SQL
29 lines
575 B
SQL
-- 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;
|