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
Tyler Perkins b621ced611
All checks were successful
continuous-integration/drone/push Build is passing
Add article DAO
2022-12-23 15:58:54 -05:00

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;