UPDATE: Added VOD table and moved is_live to the users table

This commit is contained in:
2025-02-05 13:48:42 +00:00
parent a7bbc75f3a
commit 4c79c80f3d
4 changed files with 32 additions and 10 deletions

Binary file not shown.

View File

@@ -41,11 +41,24 @@ CREATE TABLE streams
stream_id INTEGER PRIMARY KEY AUTOINCREMENT, stream_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
title TEXT NOT NULL, title TEXT NOT NULL,
start_time DATETIME NOT NULL, datetime DATETIME NOT NULL,
num_viewers INTEGER NOT NULL DEFAULT 0, num_viewers INTEGER NOT NULL DEFAULT 0,
isLive BOOLEAN NOT NULL DEFAULT 0, category_id INTEGER NOT NULL,
vod_id INTEGER,
category_id NOT NULL,
FOREIGN KEY (category_id) REFERENCES categories(category_id) ON DELETE CASCADE, FOREIGN KEY (category_id) REFERENCES categories(category_id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
DROP TABLE IF EXISTS vods;
CREATE TABLE vods
(
vod_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
title TEXT NOT NULL,
datetime DATETIME NOT NULL,
category_id INTEGER,
length INTEGER NOT NULL,
views INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (category_id) REFERENCES categories(category_id) ON DELETE CASCADE
); );

View File

@@ -51,12 +51,20 @@ INSERT INTO categories (category_name) VALUES
('Sports'); ('Sports');
-- Sample Data for streams -- Sample Data for streams
INSERT INTO streams (user_id, title, start_time, num_viewers, isLive, vod_id, category_id) VALUES INSERT INTO streams (user_id, title, datetime, num_viewers, category_id) VALUES
(1, 'Epic Gaming Session', '2025-01-25 18:00:00', 150, 1, NULL, 1), (1, 'Epic Gaming Session', '2025-01-25 18:00:00', 150, 1),
(2, 'Live Music Jam', '2025-01-25 20:00:00', 350, 1, NULL, 2), (2, 'Live Music Jam', '2025-01-25 20:00:00', 350, 2),
(3, 'Sketching Live', '2025-01-24 15:00:00', 80, 0, 201, 3), (3, 'Sketching Live', '2025-01-24 15:00:00', 80, 3),
(4, 'Math Made Easy', '2025-01-23 10:00:00', 400, 0, 202, 4), (4, 'Math Made Easy', '2025-01-23 10:00:00', 400, 4),
(5, 'Sports Highlights', '2025-01-25 12:00:00', 500, 1, NULL, 5); (5, 'Sports Highlights', '2025-01-25 12:00:00', 500, 5);
-- Sample Data for vods
INSERT INTO vods (user_id, title, datetime, category_id, length, views) VALUES
(1, 'Epic Gaming Session', '2025-01-23 18:00:00', 1, 120, 500),
(2, 'Live Music Jam', '2025-01-21 20:00:00', 2, 180, 800),
(3, 'Sketching Live', '2025-01-22 15:00:00', 3, 90, 300),
(4, 'Math Made Easy', '2025-01-21 10:00:00', 4, 150, 600),
(5, 'Sports Highlights', '2025-01-19 12:00:00', 5, 210, 700);
-- Sample Data for tags -- Sample Data for tags
INSERT INTO tags(tag_name) VALUES INSERT INTO tags(tag_name) VALUES

View File

@@ -8,6 +8,7 @@ CREATE TABLE users
num_followers INTEGER NOT NULL, num_followers INTEGER NOT NULL,
stream_key VARCHAR(60) NOT NULL, stream_key VARCHAR(60) NOT NULL,
is_partnered BOOLEAN NOT NULL DEFAULT 0, is_partnered BOOLEAN NOT NULL DEFAULT 0,
is_live BOOLEAN NOT NULL DEFAULT 0,
bio VARCHAR(1024), bio VARCHAR(1024),
current_stream_title VARCHAR(100), current_stream_title VARCHAR(100),