-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
73 lines (67 loc) · 2.48 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- Table languages
CREATE TABLE languages
(
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
lang VARCHAR(7) NOT NULL UNIQUE KEY,
locale CHAR(2) NOT NULL UNIQUE KEY,
description VARCHAR(255) NOT NULL
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Table users
CREATE TABLE users
(
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
lang_id INT UNSIGNED NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
channel VARCHAR(255) NOT NULL,
title VARCHAR(255),
description TEXT,
url VARCHAR(255),
avatar VARCHAR(255),
registered INT UNSIGNED NOT NULL,
role TINYINT UNSIGNED NOT NULL DEFAULT (0),
CONSTRAINT FOREIGN KEY (lang_id) REFERENCES languages(id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Table videos
CREATE TABLE videos
(
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
lang_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
src VARCHAR(255) NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
uploaded INT UNSIGNED NOT NULL,
status TINYINT UNSIGNED NOT NULL,
published INT UNSIGNED,
views INT UNSIGNED NOT NULL DEFAULT(0),
CONSTRAINT FOREIGN KEY (lang_id) REFERENCES languages(id),
CONSTRAINT FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Table comments
CREATE TABLE comments
(
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
lang_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
comment TEXT NOT NULL,
published INT UNSIGNED NOT NULL,
CONSTRAINT FOREIGN KEY (lang_id) REFERENCES languages(id),
CONSTRAINT FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Table likes
CREATE TABLE likes
(
user_id INT UNSIGNED NOT NULL,
video_id INT UNSIGNED NOT NULL,
CONSTRAINT PRIMARY KEY(user_id, video_id)
) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- Insertions for languages
INSERT INTO languages (lang, locale, description) VALUES
('en', 'GB', 'English'),
('es', 'ES', 'Español'),
('fr', 'FR', 'Français'),
('pt', 'PT', 'Português');
-- Insertions for users
INSERT INTO users (lang_id, email, password, channel, description, url, registered, role)
VALUES(1, 'contact@victor-brito.name', '123456', 'webdevbynight', 'Front-end developer', 'https://victor-brito.dev', UNIX_TIMESTAMP(), 1);