-
Notifications
You must be signed in to change notification settings - Fork 0
/
Empty_DB
59 lines (49 loc) · 1.65 KB
/
Empty_DB
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
-- Script to Import Data into an Empty Database.
-- Create Tables
CREATE TABLE Consumer (
ConsumerID (PK, VARCHAR2(10) PRIMARY KEY,
ConsumerName (VARCHAR2(50),
Age (NUMBER(3),
Gender (VARCHAR2(10),
Location (VARCHAR2(50),
RegistrationID (DATE)
);
-- CREATE TABLE YTVideo (
VideoID CHAR(15) PRIMARY KEY,
CategoryID VARCHAR(30),
Title VARCHAR2(55),
Date DATE,
Likes INTEGER,
Dislikes INTEGER,
Comments VARCHAR2(100),
Views INTEGER
Duration INTERVAL
);
CREATE TABLE Channel (
ChannelName VARCHAR2(60) PRIMARY KEY,
ChannelType VARCHAR2(30),
SubscribersCount INTEGER,
Videos INTEGER,
VideoViews INTEGER,
Country CHAR,
);
-- Import data from CSV files into the Video table,
-- Note: The import commands and file paths may need to be adjusted based on your specific SQL database system and file locations.
-- This part will vary depending on your specific SQL database tools and commands.
-- Example 1:
-- Import data into the Consumer table
COPY Consumer(ConsumerID, ConsumerName, Age, Gender, Location, RegistrationID)
FROM '/Users/Username/Desktop/Fall2023/CNIT372/Youtube Statistics/videos-stats.csv'
DELIMITER ','
CSV HEADER;
-- Example 2:
-- Import data into YTVideo table
COPY YTVideo(VideoID, CategoryID ,Title,Date,Likes,Dislikes,Comments,Views,Duration)
FROM '/Users/Username/Desktop/Fall2023/CNIT372/Youtube Statistics/videos-stats.csv'
DELIMITER ','
CSV HEADER;
-- Import data into the Channel table
COPY Channel(ChannelName, ChannelType, SubscribersCount, Videos, VideoViews,Country)
FROM '/Users/Username/Desktop/Fall2023/CNIT372/Youtube Statistics/comments.csv'
DELIMITER ','
CSV HEADER;