2024-04-02 19:38:16 +02:00
|
|
|
DROP TABLE IF EXISTS articles_tags;
|
|
|
|
DROP TABLE IF EXISTS tags;
|
|
|
|
DROP TABLE IF EXISTS articles;
|
|
|
|
DROP TABLE IF EXISTS issues;
|
|
|
|
DROP TABLE IF EXISTS users;
|
|
|
|
|
|
|
|
CREATE TABLE users (
|
|
|
|
id INT AUTO_INCREMENT,
|
|
|
|
username VARCHAR(15) NOT NULL UNIQUE,
|
|
|
|
password VARCHAR(60) NOT NULL,
|
|
|
|
first_name VARCHAR(50) NOT NULL,
|
|
|
|
last_name VARCHAR(50) NOT NULL,
|
|
|
|
role INT NOT NULL,
|
2024-08-25 11:24:03 +02:00
|
|
|
PRIMARY KEY (id)
|
2024-04-02 19:38:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE issues (
|
|
|
|
id INT AUTO_INCREMENT,
|
|
|
|
published BOOL NOT NULL,
|
2024-08-25 11:24:03 +02:00
|
|
|
PRIMARY KEY (id)
|
2024-04-02 19:38:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE articles (
|
|
|
|
id INT AUTO_INCREMENT,
|
|
|
|
title VARCHAR(255) NOT NULL,
|
|
|
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
description TEXT NOT NULL,
|
2024-08-30 21:20:29 +02:00
|
|
|
link VARCHAR(255),
|
2024-08-30 23:43:01 +02:00
|
|
|
enc_url VARCHAR(255),
|
|
|
|
enc_length INT,
|
|
|
|
enc_type VARCHAR(255),
|
2024-04-02 19:38:16 +02:00
|
|
|
published BOOL NOT NULL,
|
|
|
|
rejected BOOL NOT NULL,
|
|
|
|
author_id INT NOT NULL,
|
|
|
|
issue_id INT NOT NULL,
|
2024-08-25 11:24:03 +02:00
|
|
|
PRIMARY KEY (id),
|
|
|
|
FOREIGN KEY (author_id) REFERENCES users (id),
|
|
|
|
FOREIGN KEY (issue_id) REFERENCES issues (id)
|
2024-04-02 19:38:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE tags (
|
|
|
|
id INT AUTO_INCREMENT,
|
2024-04-03 19:47:27 +02:00
|
|
|
name VARCHAR(50) NOT NULL UNIQUE,
|
2024-08-25 11:24:03 +02:00
|
|
|
PRIMARY KEY (id)
|
2024-04-02 19:38:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE articles_tags (
|
|
|
|
article_id INT,
|
|
|
|
tag_id INT,
|
2024-08-25 11:24:03 +02:00
|
|
|
PRIMARY KEY (article_id, tag_id),
|
|
|
|
FOREIGN KEY (article_id) REFERENCES articles (id),
|
|
|
|
FOREIGN KEY (tag_id) REFERENCES tags (id)
|
2024-04-02 19:38:16 +02:00
|
|
|
);
|