-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.sql
More file actions
executable file
·39 lines (36 loc) · 1.47 KB
/
database.sql
File metadata and controls
executable file
·39 lines (36 loc) · 1.47 KB
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
CREATE DATABASE IF NOT EXISTS YouTubeStats;
USE YouTubeStats;
CREATE TABLE Channels (
channelId VARCHAR(255) PRIMARY KEY,
channelName VARCHAR(255) NOT NULL,
dayCollected DATE NOT NULL,
numberOfSubscribers INT,
numberOfVideos INT
);
CREATE TABLE Videos (
videoId VARCHAR(255) PRIMARY KEY,
channelId VARCHAR(255),
videoTitle VARCHAR(255) NOT NULL,
videoAudio TEXT, -- Path/URL to audio file
videoTranscript TEXT, -- Whisper-generated transcript
viewCount INT,
likeCount INT,
commentCount INT,
publishedAt DATETIME NOT NULL,
collectedDate DATE NOT NULL, -- Date video data was collected by the researcher
FOREIGN KEY (channelId) REFERENCES Channels(channelId) ON DELETE CASCADE
);
-- stores both comments and replies
CREATE TABLE Comments (
commentId VARCHAR(255) PRIMARY KEY, -- Use YouTube's comment/reply ID
videoId VARCHAR(255) NOT NULL, -- Direct link to video
parentCommentId VARCHAR(255), -- NULL = top-level comment, NOT NULL = reply
userId VARCHAR(255) NOT NULL,
userName VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
likeCount INT,
publishedAt DATETIME NOT NULL, -- Original timestamp
collectedDate DATE NOT NULL, -- Date data was collected by the researcher
FOREIGN KEY (videoId) REFERENCES Videos(videoId) ON DELETE CASCADE,
FOREIGN KEY (parentCommentId) REFERENCES Comments(commentId) ON DELETE CASCADE
);