diff --git a/SQL/create.sql b/SQL/create.sql new file mode 100644 index 0000000..d510e15 --- /dev/null +++ b/SQL/create.sql @@ -0,0 +1,237 @@ +--Create roles table +CREATE TABLE Roles +( + RoleID int IDENTITY NOT NULL PRIMARY KEY, + RoleName VARCHAR(255) Not Null +); +GO + +--Create users table +CREATE TABLE Users +( + UserID int IDENTITY NOT NULL PRIMARY KEY, + UserName VARCHAR(25) NOT NULL, + LikeCount int NOT NULL, + UserDescription TEXT +); +GO + + +--Create profilepicture table +CREATE TABLE ProfilePicture +( + PictureID int IDENTITY NOT NULL PRIMARY KEY, + UserID int NOT NULL FOREIGN KEY REFERENCES Users(UserID), + PictureFileName VARCHAR(255) NOT NULL, + Height int NOT NULL, + Width int NOT NULL +); +GO + +--Create airedtypes table +CREATE TABLE AiredTypes +( + AiredTypeID int IDENTITY NOT NULL PRIMARY KEY, + AiredType VARCHAR(255) NOT NULL +); +GO + +--Create videofiletypes table +CREATE TABLE VideoFileTypes +( + FileTypeID int IDENTITY NOT NULL PRIMARY KEY, + TypeName VARCHAR(255) NOT NULL, + TypeExtension VARCHAR(10) NOT NULL, + Codec VARCHAR(255) NOT NULL +); +GO + +--Create table videoencode +CREATE TABLE VideoEncode +( + EncodeID int IDENTITY NOT NULL PRIMARY KEY, + EncodeName VARCHAR(255) NOT NULL, + Width int NOT NULL, + Height int NOT NULL, + Framerate int NOT NULL +); +GO + +--Create category table +CREATE TABLE Category +( + CategoryID int IDENTITY NOT NULL PRIMARY KEY, + CategoryName VARCHAR(255) NOT NULL +); +GO + +--Create production table +CREATE TABLE Production +( + ProductionID int IDENTITY NOT NULL PRIMARY KEY, + ProductionName VARCHAR(255) NOT NULL +); +GO + + +--Create audiogenre table +CREATE TABLE AudioGenre +( + GenreID int IDENTITY NOT NULL PRIMARY KEY, + GenreName VARCHAR(255) NOT NULL +); +GO + +--Create releasetype table +CREATE TABLE ReleaseType +( + ReleaseTypeID int IDENTITY NOT NULL PRIMARY KEY, + TypeName VARCHAR(255) NOT NULL +); +GO + +--Create audiofiletypes table +CREATE TABLE AudioFileTypes +( + FileTypeID int IDENTITY NOT NULL PRIMARY KEY, + TypeName VARCHAR(255) NOT NULL, + TypeExtention VARCHAR(10) NOT NULL +); +GO + +--Create imagefiletypes table +CREATE TABLE ImageFileTypes +( + FileTypeID int IDENTITY NOT NULL PRIMARY KEY, + FileTypeName VARCHAR(255) NOT NULL, + FileTypeExtension VARCHAR(10) NOT NULL +); +GO + +--Create roleallocation table +CREATE TABLE RoleAllocation +( + RoleAllocationID int IDENTITY NOT NULL PRIMARY KEY, + UserID int NOT NULL FOREIGN KEY REFERENCES Users(UserID), + RoleID int NOT NULL FOREIGN KEY REFERENCES Roles(RoleID) +); +GO + +--Create mediaentry table (INTERESTING TABLE) +CREATE TABLE MediaEntry +( + EntryID int NOT NULL IDENTITY PRIMARY KEY, + CategoryID int NOT NULL FOREIGN KEY REFERENCES Category(CategoryID), + UserID int NOT NULL FOREIGN KEY REFERENCES Users(UserID), + ProductionID int FOREIGN KEY REFERENCES Production(ProductionID), --Entry may not have a production, can be null + Title VARCHAR(255) NOT NULL, + EntryDescription TEXT, + UploadDate DATETIME NOT NULL, + Premium BIT NOT NULL +); +GO + +--Create contentpage table +CREATE TABLE ContentPage +( + PageID int IDENTITY NOT NULL PRIMARY KEY, + EntryID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + Likes int NOT NULL, + Dislikes int NOT NULL +); +GO + +--Create comment table +CREATE TABLE Comment +( + CommentID int IDENTITY NOT NULL PRIMARY KEY, + UserID int NOT NULL FOREIGN KEY REFERENCES Users(UserID), + PageID int NOT NULL FOREIGN KEY REFERENCES ContentPage(PageID), + Content TEXT NOT NULL, + ParentComment int +); +GO + +--Create thumbnail table +CREATE TABLE Thumbnail +( + ThumbnailID int IDENTITY NOT NULL PRIMARY KEY, + EntryID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + ThumbnailFileName VARCHAR(255) NOT NULL, + Height int NOT NULL, + Width int NOT NULL +); +GO + +--Create imageentry table +CREATE TABLE ImageEntry +( + ImageID int IDENTITY NOT NULL PRIMARY KEY, + EntryID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + FileTypeID int NOT NULL FOREIGN KEY REFERENCES ImageFileTypes(FileTypeID), + ImageFileName VARCHAR(255) NOT NULL, + Height int NOT NULL, + Width int NOT NULL +); +GO + +--Create audioentry table +CREATE TABLE AudioEntry +( + AudioID int IDENTITY NOT NULL PRIMARY KEY, + EntryID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + FileTypeID int NOT NULL FOREIGN KEY REFERENCES AudioFileTypes(FileTypeID), + ReleaseTypeID int NOT NULL FOREIGN KEY REFERENCES ReleaseType(ReleaseTypeID), + AudioLength int NOT NULL, + BitRate int NOT NULL, + AudioFileName VARCHAR(255) NOT NULL +); +GO + +--Create audiopreview table +CREATE TABLE AudioPreview +( + PreviewID int IDENTITY NOT NULL PRIMARY KEY, + AudioID int NOT NULL FOREIGN KEY REFERENCES AudioEntry(AudioID), + FileTypeID int NOT NULL FOREIGN KEY REFERENCES AudioFileTypes(FileTypeID), + AudioLength int NOT NULL, + BitRate int NOT NULL, + AudioFileName VARCHAR(255) NOT NULL +); +GO + +--Create videoentry table +CREATE TABLE VideoEntry +( + VideoID int IDENTITY NOT NULL PRIMARY KEY, + EntryID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + EncodeID int NOT NULL FOREIGN KEY REFERENCES VideoEncode(EncodeID), + FileTypeID int NOT NULL FOREIGN KEY REFERENCES VideoFileTypes(FileTypeID), + AiredTypeID int FOREIGN KEY REFERENCES AiredTypes(AiredTypeID), + VideoFileName VARCHAR(255) NOT NULL, + AiredOn DATETIME, + Length int NOT NULL +); +GO + +--Create videopreview table +CREATE TABLE VideoPreview +( + PreviewID int IDENTITY NOT NULL PRIMARY KEY, + VideoID int NOT NULL FOREIGN KEY REFERENCES MediaEntry(EntryID), + EncodeID int NOT NULL FOREIGN KEY REFERENCES VideoEncode(EncodeID), + FileTypeID int NOT NULL FOREIGN KEY REFERENCES VideoFileTypes(FileTypeID), + VideoFileName VARCHAR(255) NOT NULL, + AiredOn DATETIME, + Length int NOT NULL, +); +GO + +--Create audiogenreentry table (solve many to many relationship) +CREATE TABLE AudioGenreEntry +( + GenreEntryID int IDENTITY NOT NULL PRIMARY KEY, + AudioID int NOT NULL FOREIGN KEY REFERENCES AudioEntry(AudioID), + GenreID int NOT NULL FOREIGN KEY REFERENCES AudioGenre(GenreID) +); +GO diff --git a/SQL/create_and_insert_generated.sql b/SQL/create_and_insert_generated.sql new file mode 100644 index 0000000..298f63b Binary files /dev/null and b/SQL/create_and_insert_generated.sql differ diff --git a/SQL/create_generated.sql b/SQL/create_generated.sql new file mode 100644 index 0000000..253f175 Binary files /dev/null and b/SQL/create_generated.sql differ diff --git a/SQL/drop.sql b/SQL/drop.sql new file mode 100644 index 0000000..7d19da3 Binary files /dev/null and b/SQL/drop.sql differ diff --git a/SQL/individual_creates/1 - Roles.Table.sql b/SQL/individual_creates/1 - Roles.Table.sql new file mode 100644 index 0000000..5731fc8 Binary files /dev/null and b/SQL/individual_creates/1 - Roles.Table.sql differ diff --git a/SQL/individual_creates/10 - ReleaseType.Table.sql b/SQL/individual_creates/10 - ReleaseType.Table.sql new file mode 100644 index 0000000..6b42090 Binary files /dev/null and b/SQL/individual_creates/10 - ReleaseType.Table.sql differ diff --git a/SQL/individual_creates/11 - AudioFileTypes.Table.sql b/SQL/individual_creates/11 - AudioFileTypes.Table.sql new file mode 100644 index 0000000..9ba896a Binary files /dev/null and b/SQL/individual_creates/11 - AudioFileTypes.Table.sql differ diff --git a/SQL/individual_creates/12 - ImageFileTypes.Table.sql b/SQL/individual_creates/12 - ImageFileTypes.Table.sql new file mode 100644 index 0000000..fcef4b9 Binary files /dev/null and b/SQL/individual_creates/12 - ImageFileTypes.Table.sql differ diff --git a/SQL/individual_creates/13 - RoleAllocation.Table.sql b/SQL/individual_creates/13 - RoleAllocation.Table.sql new file mode 100644 index 0000000..2005be2 Binary files /dev/null and b/SQL/individual_creates/13 - RoleAllocation.Table.sql differ diff --git a/SQL/individual_creates/14 - MediaEntry.Table.sql b/SQL/individual_creates/14 - MediaEntry.Table.sql new file mode 100644 index 0000000..e0ce9ab Binary files /dev/null and b/SQL/individual_creates/14 - MediaEntry.Table.sql differ diff --git a/SQL/individual_creates/15 - ContentPage.Table.sql b/SQL/individual_creates/15 - ContentPage.Table.sql new file mode 100644 index 0000000..4cb2ba3 Binary files /dev/null and b/SQL/individual_creates/15 - ContentPage.Table.sql differ diff --git a/SQL/individual_creates/16 - Comment.Table.sql b/SQL/individual_creates/16 - Comment.Table.sql new file mode 100644 index 0000000..746dc6e Binary files /dev/null and b/SQL/individual_creates/16 - Comment.Table.sql differ diff --git a/SQL/individual_creates/17 - Thumbnail.Table.sql b/SQL/individual_creates/17 - Thumbnail.Table.sql new file mode 100644 index 0000000..9a224b9 Binary files /dev/null and b/SQL/individual_creates/17 - Thumbnail.Table.sql differ diff --git a/SQL/individual_creates/18 - ImageEntry.Table.sql b/SQL/individual_creates/18 - ImageEntry.Table.sql new file mode 100644 index 0000000..dc3f2b2 Binary files /dev/null and b/SQL/individual_creates/18 - ImageEntry.Table.sql differ diff --git a/SQL/individual_creates/19 - AudioEntry.Table.sql b/SQL/individual_creates/19 - AudioEntry.Table.sql new file mode 100644 index 0000000..a5b63c5 Binary files /dev/null and b/SQL/individual_creates/19 - AudioEntry.Table.sql differ diff --git a/SQL/individual_creates/2 - Users.Table.sql b/SQL/individual_creates/2 - Users.Table.sql new file mode 100644 index 0000000..64b68a1 Binary files /dev/null and b/SQL/individual_creates/2 - Users.Table.sql differ diff --git a/SQL/individual_creates/20 - AudioPreview.Table.sql b/SQL/individual_creates/20 - AudioPreview.Table.sql new file mode 100644 index 0000000..2e45c20 Binary files /dev/null and b/SQL/individual_creates/20 - AudioPreview.Table.sql differ diff --git a/SQL/individual_creates/21 - dbo.VideoEntry.Table.sql b/SQL/individual_creates/21 - dbo.VideoEntry.Table.sql new file mode 100644 index 0000000..78b7ce0 Binary files /dev/null and b/SQL/individual_creates/21 - dbo.VideoEntry.Table.sql differ diff --git a/SQL/individual_creates/22 - VideoPreview.Table.sql b/SQL/individual_creates/22 - VideoPreview.Table.sql new file mode 100644 index 0000000..d2ff458 Binary files /dev/null and b/SQL/individual_creates/22 - VideoPreview.Table.sql differ diff --git a/SQL/individual_creates/23 - AudioGenreEntry.Table.sql b/SQL/individual_creates/23 - AudioGenreEntry.Table.sql new file mode 100644 index 0000000..819dac2 Binary files /dev/null and b/SQL/individual_creates/23 - AudioGenreEntry.Table.sql differ diff --git a/SQL/individual_creates/3 - ProfilePicture.Table.sql b/SQL/individual_creates/3 - ProfilePicture.Table.sql new file mode 100644 index 0000000..e94f93a Binary files /dev/null and b/SQL/individual_creates/3 - ProfilePicture.Table.sql differ diff --git a/SQL/individual_creates/4 - AiredTypes.Table.sql b/SQL/individual_creates/4 - AiredTypes.Table.sql new file mode 100644 index 0000000..ea2a11a Binary files /dev/null and b/SQL/individual_creates/4 - AiredTypes.Table.sql differ diff --git a/SQL/individual_creates/5 - VideoFileTypes.Table.sql b/SQL/individual_creates/5 - VideoFileTypes.Table.sql new file mode 100644 index 0000000..459b548 Binary files /dev/null and b/SQL/individual_creates/5 - VideoFileTypes.Table.sql differ diff --git a/SQL/individual_creates/6 - VideoEncode.Table.sql b/SQL/individual_creates/6 - VideoEncode.Table.sql new file mode 100644 index 0000000..0d053bd Binary files /dev/null and b/SQL/individual_creates/6 - VideoEncode.Table.sql differ diff --git a/SQL/individual_creates/7 - Category.Table.sql b/SQL/individual_creates/7 - Category.Table.sql new file mode 100644 index 0000000..c30d7f8 Binary files /dev/null and b/SQL/individual_creates/7 - Category.Table.sql differ diff --git a/SQL/individual_creates/8 - Production.Table.sql b/SQL/individual_creates/8 - Production.Table.sql new file mode 100644 index 0000000..bb6f80c Binary files /dev/null and b/SQL/individual_creates/8 - Production.Table.sql differ diff --git a/SQL/individual_creates/9 - AudioGenre.Table.sql b/SQL/individual_creates/9 - AudioGenre.Table.sql new file mode 100644 index 0000000..9b5169c Binary files /dev/null and b/SQL/individual_creates/9 - AudioGenre.Table.sql differ diff --git a/SQL/individual_creates/MediaLibrary.Database.sql b/SQL/individual_creates/MediaLibrary.Database.sql new file mode 100644 index 0000000..c4e502a Binary files /dev/null and b/SQL/individual_creates/MediaLibrary.Database.sql differ diff --git a/SQL/individual_inserts/1 - Roles.Table.sql b/SQL/individual_inserts/1 - Roles.Table.sql new file mode 100644 index 0000000..bf0068d Binary files /dev/null and b/SQL/individual_inserts/1 - Roles.Table.sql differ diff --git a/SQL/individual_inserts/10 - ReleaseType.Table.sql b/SQL/individual_inserts/10 - ReleaseType.Table.sql new file mode 100644 index 0000000..ffb1b37 Binary files /dev/null and b/SQL/individual_inserts/10 - ReleaseType.Table.sql differ diff --git a/SQL/individual_inserts/11 - AudioFileTypes.Table.sql b/SQL/individual_inserts/11 - AudioFileTypes.Table.sql new file mode 100644 index 0000000..8f6c842 Binary files /dev/null and b/SQL/individual_inserts/11 - AudioFileTypes.Table.sql differ diff --git a/SQL/individual_inserts/12 - ImageFileTypes.Table.sql b/SQL/individual_inserts/12 - ImageFileTypes.Table.sql new file mode 100644 index 0000000..fede111 Binary files /dev/null and b/SQL/individual_inserts/12 - ImageFileTypes.Table.sql differ diff --git a/SQL/individual_inserts/13 - RoleAllocation.Table.sql b/SQL/individual_inserts/13 - RoleAllocation.Table.sql new file mode 100644 index 0000000..ae08602 Binary files /dev/null and b/SQL/individual_inserts/13 - RoleAllocation.Table.sql differ diff --git a/SQL/individual_inserts/14 - MediaEntry.Table.sql b/SQL/individual_inserts/14 - MediaEntry.Table.sql new file mode 100644 index 0000000..d1236c5 Binary files /dev/null and b/SQL/individual_inserts/14 - MediaEntry.Table.sql differ diff --git a/SQL/individual_inserts/15 - ContentPage.Table.sql b/SQL/individual_inserts/15 - ContentPage.Table.sql new file mode 100644 index 0000000..6436936 Binary files /dev/null and b/SQL/individual_inserts/15 - ContentPage.Table.sql differ diff --git a/SQL/individual_inserts/16 - Comment.Table.sql b/SQL/individual_inserts/16 - Comment.Table.sql new file mode 100644 index 0000000..cb754ad Binary files /dev/null and b/SQL/individual_inserts/16 - Comment.Table.sql differ diff --git a/SQL/individual_inserts/17 - Thumbnail.Table.sql b/SQL/individual_inserts/17 - Thumbnail.Table.sql new file mode 100644 index 0000000..87d7168 Binary files /dev/null and b/SQL/individual_inserts/17 - Thumbnail.Table.sql differ diff --git a/SQL/individual_inserts/18 - ImageEntry.Table.sql b/SQL/individual_inserts/18 - ImageEntry.Table.sql new file mode 100644 index 0000000..2c4122f Binary files /dev/null and b/SQL/individual_inserts/18 - ImageEntry.Table.sql differ diff --git a/SQL/individual_inserts/19 - AudioEntry.Table.sql b/SQL/individual_inserts/19 - AudioEntry.Table.sql new file mode 100644 index 0000000..5f12eff Binary files /dev/null and b/SQL/individual_inserts/19 - AudioEntry.Table.sql differ diff --git a/SQL/individual_inserts/2 - Users.Table.sql b/SQL/individual_inserts/2 - Users.Table.sql new file mode 100644 index 0000000..fca85a5 Binary files /dev/null and b/SQL/individual_inserts/2 - Users.Table.sql differ diff --git a/SQL/individual_inserts/20 - AudioPreview.Table.sql b/SQL/individual_inserts/20 - AudioPreview.Table.sql new file mode 100644 index 0000000..120a3cd Binary files /dev/null and b/SQL/individual_inserts/20 - AudioPreview.Table.sql differ diff --git a/SQL/individual_inserts/21 - VideoEntry.Table.sql b/SQL/individual_inserts/21 - VideoEntry.Table.sql new file mode 100644 index 0000000..a95885d Binary files /dev/null and b/SQL/individual_inserts/21 - VideoEntry.Table.sql differ diff --git a/SQL/individual_inserts/22 - VideoPreview.Table.sql b/SQL/individual_inserts/22 - VideoPreview.Table.sql new file mode 100644 index 0000000..61564ea Binary files /dev/null and b/SQL/individual_inserts/22 - VideoPreview.Table.sql differ diff --git a/SQL/individual_inserts/23 - AudioGenreEntry.Table.sql b/SQL/individual_inserts/23 - AudioGenreEntry.Table.sql new file mode 100644 index 0000000..ef38e98 Binary files /dev/null and b/SQL/individual_inserts/23 - AudioGenreEntry.Table.sql differ diff --git a/SQL/individual_inserts/3 - ProfilePicture.Table.sql b/SQL/individual_inserts/3 - ProfilePicture.Table.sql new file mode 100644 index 0000000..9d9538a Binary files /dev/null and b/SQL/individual_inserts/3 - ProfilePicture.Table.sql differ diff --git a/SQL/individual_inserts/4 - dbo.AiredTypes.Table.sql b/SQL/individual_inserts/4 - dbo.AiredTypes.Table.sql new file mode 100644 index 0000000..27ec96e Binary files /dev/null and b/SQL/individual_inserts/4 - dbo.AiredTypes.Table.sql differ diff --git a/SQL/individual_inserts/5 - VideoFileTypes.Table.sql b/SQL/individual_inserts/5 - VideoFileTypes.Table.sql new file mode 100644 index 0000000..cf1358e Binary files /dev/null and b/SQL/individual_inserts/5 - VideoFileTypes.Table.sql differ diff --git a/SQL/individual_inserts/6 - VideoEncode.Table.sql b/SQL/individual_inserts/6 - VideoEncode.Table.sql new file mode 100644 index 0000000..c6f610e Binary files /dev/null and b/SQL/individual_inserts/6 - VideoEncode.Table.sql differ diff --git a/SQL/individual_inserts/7 - Category.Table.sql b/SQL/individual_inserts/7 - Category.Table.sql new file mode 100644 index 0000000..4c02a7a Binary files /dev/null and b/SQL/individual_inserts/7 - Category.Table.sql differ diff --git a/SQL/individual_inserts/8 - Production.Table.sql b/SQL/individual_inserts/8 - Production.Table.sql new file mode 100644 index 0000000..0b07c57 Binary files /dev/null and b/SQL/individual_inserts/8 - Production.Table.sql differ diff --git a/SQL/individual_inserts/9 - AudioGenre.Table.sql b/SQL/individual_inserts/9 - AudioGenre.Table.sql new file mode 100644 index 0000000..512252b Binary files /dev/null and b/SQL/individual_inserts/9 - AudioGenre.Table.sql differ diff --git a/SQL/insert.sql b/SQL/insert.sql new file mode 100644 index 0000000..c4fe307 --- /dev/null +++ b/SQL/insert.sql @@ -0,0 +1,381 @@ +--Insert data into roles table +INSERT INTO Roles (RoleName) +VALUES + ('Premium'), + ('VIP'), + ('Uploader'), + ('Administrator'), + ('Moderator'), + ('Content Janitor') + + +--Insert data into users table +INSERT INTO Users (UserName, LikeCount, UserDescription) +VALUES + ('WickedWorm', 8025, 'I am the social media director of WB. I post new WB content when released.'), + ('NailVista', 2407, 'I post jokes on the internet.'), + ('ExtremeRefined', 2641, 'I post comedy videos from my own bedroom.'), + ('KnowGem', 2030, 'Solo music artist focusing in rock'), + ('EmergeReal', 6343, 'Owner of site. If you need help feel free to ask me :)'), + ('ArmWhoa', 2460, 'Look out for new releases coming soon!'), + ('IcedTeaDramatic', 9231, 'I am the artistic director of WB, I post stuff for upcoming projects.'), + ('WisBerserk56', 466, NULL), + ('Play4Ask', -2357, 'I post my thoughts on the internet.'), + ('FeatTiffin', 54, 'I like to view good media.'), + ('Butter4Real', 4, NULL), + ('Stickyundefined', -6, NULL), + ('KickerOne', -145, NULL), + ('ImPrivate', 0, NULL), + ('OMGTHE1', -2, NULL) + + +--Insert data into profilepicture table +INSERT INTO ProfilePicture (UserID, PictureFileName, Height, Width) +VALUES + (1, 'flower.jpeg', 500, 500), + (2, 'car.jpeg', 550, 550), + (3, 'user_pfp.jpeg', 250, 300), + (4, 'default.png', 500, 500), + (5, 'default.png', 500, 500), + (6, 'default.png', 500, 500), + (7, 'new_profile.jpeg', 1000, 1000), + (8, 'm.jpeg', 505, 505), + (9, 'default.png', 500, 500), + (10, 'flowers.jpeg', 450, 500), + (11, 'default.png', 500, 500), + (12, 'kb_.jpeg', 300, 500), + (13, 'default.png', 500, 500), + (14, 'default.png', 500, 500), + (15, 'me_irl.jpeg', 1200, 1200) + + +--Insert data into airedtypes table +INSERT INTO AiredTypes(AiredType) +VALUES + ('TV Show'), + ('Movie'), + ('PSA'), + ('Play'), + ('Home Made'), + ('Premiere'), + ('Live Action') + + + +--Insert data into videofiletypes table +INSERT INTO VideoFileTypes(TypeName, TypeExtension, Codec) +VALUES + ('WebM', '.webm', 'VP8, VP9'), + ('Flash Video', '.flv', 'H.264'), + ('AVI', '.avi', 'AVI'), + ('QuickTime File Format', '.mov', 'QuickTime'), + ('Windows Media Video', '.wmv', 'ASF'), + ('MPEG-4', '.mp4', 'MPEG-4') + + +--Insert data into videoencode table +INSERT INTO VideoEncode(EncodeName, Width, Height, Framerate) +VALUES + ('1080p60', 1920, 1080, 60), + ('1080p30', 1920, 1080, 30), + ('720p60', 1280, 720, 60), + ('720p30', 1280, 720, 30), + ('480p60', 848, 480, 60), + ('480p30', 848, 480, 30), + ('1440p30', 2560, 1440, 30), + ('1440p60', 2560, 1440, 60), + ('2160p30', 3840, 2160, 30), + ('2160p60', 3840, 2160, 60) + + +--Insert data into category table +INSERT INTO Category(CategoryName) +VALUES + ('Comedy'), + ('Education'), + ('Entertainment'), + ('Film'), + ('Animation'), + ('Show'), + ('Gaming'), + ('News'), + ('Vlogs/Blogs'), + ('Technology'), + ('Sport') + + +--Insert data into production table +INSERT INTO Production(ProductionName) +VALUES + ('Warner Bros'), + ('Dreamworks'), + ('Disney') + + +--Insert data into audiogenre table +INSERT INTO AudioGenre(GenreName) +VALUES + ('Blues'), + ('Country'), + ('Electronic'), + ('Folk'), + ('Hip Hop'), + ('Jazz'), + ('Pop'), + ('R%B'), + ('Rock') + + +--Insert data into releasetype table +INSERT INTO ReleaseType(TypeName) +VALUES + ('Single'), + ('Album'), + ('EP'), + ('One off') + + +--Insert data into audiofiletypes table +INSERT INTO AudioFileTypes (TypeName, TypeExtention) +VALUES + ('Advanced Audio Coding', '.aac'), + ('Apple AIFF', '.aiff'), + ('Free Lossless Audio Codec', '.flac'), + ('MPEG-4 Audio', '.m4a'), + ('MPEG Layer III', '.mp3'), + ('Vorbis', '.ogg'), + ('Wave', '.wav'), + ('Windows Media Audio', '.wma') + + +--Insert data into imagefiletypes table +INSERT INTO ImageFileTypes (FileTypeName, FileTypeExtension) +VALUES + ('Joint Photographic Experts Group', '.jpeg'), + ('Joint Photographic Experts Group', '.jpg'), + ('Tagged Image File Format', '.tiff'), + ('Graphics Interchange File Format', '.gif'), + ('Windows Bitmap', '.bmp'), + ('Portable Network Graphics', '.png') + + +--Insert data into roleallocation table +INSERT INTO RoleAllocation (UserID, RoleID) +VALUES + (1, 2), + (1, 3), + (2, 1), + (3, 1), + (3, 2), + (3, 3), + (4, 2), + (4, 3), + (5, 1), + (5, 2), + (5, 3), + (5, 4), + (5, 5), + (5, 6), + (6, 1), + (6, 3), + (7, 1), + (7, 2), + (7, 3), + (7, 6), + (8, 1), + (10, 1), + (14, 1), + (15, 1) + + +--Insert data into mediaentry table (INTERESTING TABLE) + +INSERT INTO MediaEntry(CategoryID, UserID, ProductionID, Title, EntryDescription, UploadDate, Premium) +VALUES + (9, 2, NULL, 'Holiday snaps! :)', 'Loving life rn!', '2018-09-09 08:23:00', 0), + (4, 1, 1, 'Oliver!', 'After being sold to a mortician, young orphan Oliver Twist runs away and meets a group of boys trained to be pickpockets by an elderly mentor.', '2018-09-09 10:34:21', 1), + (1, 11, NULL, 'Best prank EVER!', 'She should have seen it coming! haha', '2018-09-09 12:04:58', 0), + (4, 8, NULL, 'The Howling Walkway', 'From my newest album, enjoy~', '2018-09-09 16:02:51', 0), + (8, 9, 1, 'Brexit Vote Uncertain', 'UK seems to not know whether brexit will happen at all...', '2018-09-10 02:33:13', 0), + (1, 2, NULL, 'Top Gear best moments!', 'Watch these three guys rant and rave for 20 minutes!!!!', '2018-09-10 03:52:01', 0), + (3, 3, NULL, 'Fake SD Card Scam!', 'Can you believe theyre selling this?!?!', '2018-09-10 06:00:04', 0), + (1, 2, NULL, '10 WORST Christmas Presents EVER!', 'Check out some of these horrible gifts...', '2018-09-10 09:29:40', 0), + (2, 5, 3, 'Popcorn Recipies', 'Some of my fav popcorn food :)', '2018-09-10 12:52:00', 0), + (1, 8, NULL, 'Ready Meal Taste Test', 'Yeah these arent good...', '2018-09-10 20:01:59', 0), + (6, 1, 1, 'Friends: Episode 16', 'Watch Friends HERE!', '2018-09-10 23:34:02', 1), + (3, 6, NULL, 'Deconstructing Nature', 'EDM album :3', '2018-09-11 09:29:22', 1), + (3, 7, NULL, 'Upcoming projects :eyes:', 'Just a teaser for the new film', '2018-09-11 10:00:52', 1), + (3, 7, NULL, 'Upcoming projects PART 2', 'Another teaser, why not :P', '2018-09-11 10:40:23', 1), + (9, 12, NULL, 'The world is amazing.', 'So nice.', '2018-09-11 14:38:32', 0), + (6, 5, 2, 'Cars Miniseries', 'Watch miniseries here', '2018-09-11 17:52:15', 1), + (6, 1, 1, 'Friends: Episode 17-20', 'Watch friends here', '2018-09-11 19:25:50', 1) + + + +--Insert data into contentpage table +INSERT INTO ContentPage(EntryID, Likes, Dislikes) +VALUES + (1, 500, 20), + (2, 20000, 500), + (3, 1, 1), + (4, 10, 0), + (5, 150, 320), + (6, 15, 3), + (7, 120, 14), + (8, 691, 142), + (9, 351, 21), + (10, 63, 12), + (11, 898, 32), + (12, 134, 6), + (13, 1740, 348), + (14, 1294, 211), + (15, 248, 42), + (16, 673, 84), + (17, 1482, 183) + + + +--Insert data into comment table +INSERT INTO Comment(UserID, PageID, Content, ParentComment) +VALUES + (1, 1, 'Love the pics! :)', NULL), + (2, 1, 'thx', 1), + (4, 1, 'Amazing', NULL), + (2, 1, 'thanks :)', 3), + (3, 2, 'A true classic.', NULL), + (1, 2, 'Agree!', 5), + (12, 5, 'idk about this one...', NULL), + (10, 7, 'Interesting, thanks for the tip!', NULL), + (5, 11, 'Such a good show!', NULL), + (3, 12, 'Tunes!', NULL), + (15, 17, 'Thanks for the upload!', NULL), + (3, 17, 'Ta!', NULL) + + +--Insert data into thumbnail table +INSERT INTO Thumbnail(EntryID, ThumbnailFileName, Height, Width) +VALUES + (1, 'snaps.png', 1920, 1080), + (2, 'oliver.png', 1920, 1080), + (3, 'prank.png', 1000, 1000), + (4, 'walkway.png', 2000, 2000), + (5, 'brexit.png', 1500, 600), + (6, 'top_.png', 750, 400), + (7, 'fake.png', 1200, 1200), + (8, 'worst.png', 1400, 1400), + (9, 'popcorn.png', 1920, 1080), + (10, 'meal.png', 1920, 1080), + (11, 'friends16.png', 1920, 1200), + (12, 'nat.png', 720, 720), + (13, 'up.png', 4000, 4000), + (14, 'up2.png', 4000, 4000), + (15, 'amaze.png', 1500, 1500), + (16, 'cars.png', 1280, 720), + (17, 'friends.png', 1920, 1200) + + + +--Insert data into imageentry table +INSERT INTO ImageEntry(EntryID, FileTypeID, ImageFileName, Height, Width) +VALUES + (1, 1, 'snap1', 500, 500), + (1, 1, 'snap2', 500, 500), + (1, 1, 'snap3', 500, 500), + (1, 4, 'vid1', 500, 500), + (3, 2, 'prank', 1280, 720), + (13, 6, 'pic1', 4000, 4000), + (13, 6, 'pic2', 4000, 4000), + (13, 6, 'pic3', 4000, 4000), + (13, 6, 'pic4', 4000, 4000), + (13, 6, 'pic5', 4000, 4000), + (13, 4, 'clip', 1920, 1080), + (14, 4, 'clip2', 1920, 1080), + (15, 3, 'world_pic', 4500, 3500), + (15, 3, 'world_pic2', 1000, 2000) + + +--Insert data into audioentry table +INSERT INTO AudioEntry(EntryID, FileTypeID, ReleaseTypeID, AudioLength, BitRate, AudioFileName) +VALUES + (4, 7, 1, 213, 256, 'the_howling_walkway'), + (12, 5, 2, 78, 320, 'sunrise'), + (12, 5, 2, 241, 320, 'deconstructing_nature'), + (12, 5, 2, 116, 320, 'dream_field'), + (12, 5, 2, 180, 320, 'floating_through_a_frozen_atlantis'), + (12, 5, 2, 43, 320, 'interlude'), + (12, 5, 2, 205, 320, 'broadcast'), + (12, 5, 2, 335, 320, 'skyshifer_vip'), + (12, 5, 2, 161, 320, 'serotonin'), + (12, 5, 2, 232, 320, 'data_corruption_symphony'), + (12, 5, 2, 449, 320, 'cherry_blossoms_explode_across_the_dying_horizon') + + + +--Insert data into audiopreview table +INSERT INTO AudioPreview(AudioID, FileTypeID, AudioLength, BitRate, AudioFileName) +VALUES + (1, 7, 28, 320, 'the_howling_walkway_1'), + (1, 2, 10, 320, 'the_howling_walkway_2'), + (1, 2, 20, 320, 'the_howling_walkway_3'), + (8, 3, 30, 1000, 'skyshifter_vip_1'), + (8, 3, 40, 1000, 'skyshifter_vip_2'), + (11, 3, 60, 1000, 'cherry_blossoms_explode_across_the_dying_horizon_1'), + (11, 3, 30, 1000, 'cherry_blossoms_explode_across_the_dying_horizon_2') + + + +--Insert data into videoentry table +INSERT INTO VideoEntry(EntryID, EncodeID, FileTypeID, AiredTypeID, VideoFileName, AiredOn, Length) +VALUES + (2, 6, 4, 2, 'oliver!', '1968-09-27', 9180), + (5, 2, 1, 1, 'brexit_uncertain', '2018-09-09', 300), + (6, 4, 3, 1, 'top_gear_best', '2012-01-01', 1204), + (7, 1, 6, 3, 'sd_card', '2018-09-01', 513), + (8, 2, 5, 5, 'worst_presents', '2017-12-01', 295), + (9, 1, 3, 5, 'pop_reci', '2018-04-09', 196), + (10, 2, 6, 5, 'ready_meal', '2018-08-28', 302), + (11, 7, 6, 1, 'friends_s1_e16', '1995-02-23', 1440), + (16, 9, 3, 1, 'Cars_mini_1', '2017-12-04', 740), + (17, 7, 6, 1, 'friends_17', '1995-02-23', 1367), + (17, 7, 6, 1, 'friends_18', '1995-03-02', 1485), + (17, 7, 6, 1, 'friends_19', '1995-03-09', 1501), + (17, 7, 6, 1, 'friends_20', '1995-04-06', 1402) + + + +--Insert data into videopreview table +INSERT INTO VideoPreview(VideoID, EncodeID, FileTypeID, VideoFileName, AiredOn, Length) +VALUES + (1, 6, 4, 'oliver_trailer_1', '1968-09-27', 132), + (1, 6, 4, 'oliver_trailer_2', '1968-09-27', 203), + (1, 6, 4, 'oliver_trailer_3', '1968-09-27', 152), + (1, 6, 4, 'oliver_trailer_4', '1968-09-27', 173), + (6, 4, 3, 'top_gear_best_preview', '2012-01-01', 124), + (11, 7, 6, 'friends_s1_e16_preview', '1995-02-23', 90), + (16, 9, 3, 'Cars_mini_1_preview', '2017-12-04', 94), + (17, 7, 6, 'friends_17_preview_1', '1995-02-22', 101), + (17, 7, 6, 'friends_17_preview_2', '1995-02-23', 99), + (17, 7, 6, 'friends_18_preview_1', '1995-03-01', 82), + (17, 7, 6, 'friends_18_preview_2', '1995-03-02', 100), + (17, 7, 6, 'friends_19_preview', '1995-03-09', 95), + (17, 7, 6, 'friends_20_preview', '1995-04-06', 95) + + +--Insert data into audiogenreentry table +INSERT INTO AudioGenreEntry(AudioID, GenreID) +VALUES + (1, 9), + (2, 3), + (3, 3), + (4, 3), + (5, 3), + (6, 3), + (7, 3), + (8, 3), + (9, 3), + (10, 3), + (11, 3) + + + + diff --git a/SQL/insert_generated.sql b/SQL/insert_generated.sql new file mode 100644 index 0000000..2dabeea Binary files /dev/null and b/SQL/insert_generated.sql differ diff --git a/SQL/queries/DML/query 1.sql b/SQL/queries/DML/query 1.sql new file mode 100644 index 0000000..124e5f3 --- /dev/null +++ b/SQL/queries/DML/query 1.sql @@ -0,0 +1,6 @@ +CREATE PROCEDURE UpdateUserName @OldName varchar(255), @NewName varchar(255) +AS +UPDATE Users +SET UserName = @NewName, LikeCount = 0 +WHERE UserName = @OldName +GO \ No newline at end of file diff --git a/SQL/queries/DML/query 2.sql b/SQL/queries/DML/query 2.sql new file mode 100644 index 0000000..dee1fa6 --- /dev/null +++ b/SQL/queries/DML/query 2.sql @@ -0,0 +1,15 @@ +INSERT INTO MediaEntry(CategoryID, UserID, ProductionID, Title, EntryDescription, UploadDate, Premium) +VALUES + (3, 5, NULL, 'INSERT TEST', 'INSERT TEST', '2018-09-09 08:23:00', 0) + +INSERT INTO VideoEntry(EntryID, EncodeID, FileTypeID, AiredTypeID, VideoFileName, AiredOn, Length) +VALUES + (18, 6, 4, 2, 'TEST', '1968-09-27', 9180) + +INSERT INTO ImageEntry(EntryID, FileTypeID, ImageFileName, Height, Width) +VALUES + (18, 1, 'TEST', 500, 500) + +INSERT INTO ContentPage(EntryID, Likes, Dislikes) +VALUES + (18, 0, 0) \ No newline at end of file diff --git a/SQL/queries/DML/query 3.sql b/SQL/queries/DML/query 3.sql new file mode 100644 index 0000000..4cf4f49 --- /dev/null +++ b/SQL/queries/DML/query 3.sql @@ -0,0 +1,17 @@ +CREATE PROCEDURE RemoveMediaEntry @EntryID integer +AS +DELETE FROM ImageEntry +WHERE EntryID = @EntryID; +DELETE FROM AudioEntry +WHERE EntryID = @EntryID; +DELETE FROM VideoEntry +WHERE EntryID = @EntryID; +DELETE FROM Thumbnail +WHERE EntryID = @EntryID; +DELETE FROM Comment +WHERE PageID = @EntryID; +DELETE FROM ContentPage +WHERE PageID = @EntryID; +DELETE FROM MediaEntry +WHERE EntryID = @EntryID; +GO \ No newline at end of file diff --git a/SQL/queries/DML/query 4.sql b/SQL/queries/DML/query 4.sql new file mode 100644 index 0000000..1222386 --- /dev/null +++ b/SQL/queries/DML/query 4.sql @@ -0,0 +1,7 @@ +INSERT INTO VideoEntry(EntryID, EncodeID, FileTypeID, AiredTypeID, VideoFileName, AiredOn, Length) +VALUES + (1, 6, 4, 2, 'ENTRY 1', '2000-08-22', 2934) + +INSERT INTO VideoFileTypes(TypeName, TypeExtension, Codec) +VALUES + ('NEW TYPE', 'NEW TYPE', 'NEW TYPE') \ No newline at end of file diff --git a/SQL/queries/DML/query 5.sql b/SQL/queries/DML/query 5.sql new file mode 100644 index 0000000..0ba221a --- /dev/null +++ b/SQL/queries/DML/query 5.sql @@ -0,0 +1,9 @@ +CREATE PROCEDURE RemoveUser @UserID integer +AS +DELETE FROM RoleAllocation +WHERE UserID = @UserID; +DELETE FROM ProfilePicture +WHERE UserID = @UserID; +DELETE FROM Comment +WHERE UserID = @UserID; +GO \ No newline at end of file diff --git a/SQL/queries/query 1.sql b/SQL/queries/query 1.sql new file mode 100644 index 0000000..7ec5033 --- /dev/null +++ b/SQL/queries/query 1.sql @@ -0,0 +1,5 @@ +SELECT UserName, RoleName +FROM Users +LEFT JOIN RoleAllocation ON RoleAllocation.UserID = Users.UserID +LEFT JOIN Roles ON Roles.RoleID = RoleAllocation.RoleID +WHERE Users.UserId = 1 \ No newline at end of file diff --git a/SQL/queries/query 2.sql b/SQL/queries/query 2.sql new file mode 100644 index 0000000..59da073 --- /dev/null +++ b/SQL/queries/query 2.sql @@ -0,0 +1,5 @@ +SELECT UserName, LikeCount, UserDescription, PictureFileName, Height, Width, Content +FROM Users +LEFT JOIN ProfilePicture ON ProfilePicture.UserID = Users.UserID +LEFT JOIN Comment ON Comment.UserID = Users.UserID +WHERE Users.UserID = 1 \ No newline at end of file diff --git a/SQL/queries/query 3.sql b/SQL/queries/query 3.sql new file mode 100644 index 0000000..7e8cb10 --- /dev/null +++ b/SQL/queries/query 3.sql @@ -0,0 +1,11 @@ +SELECT Title, EntryDescription, UploadDate, ProductionName, CategoryName, ThumbnailFileName, Likes, Dislikes, Content, ParentComment, VideoFileName, AudioFileName, ImageFileName +FROM MediaEntry +LEFT JOIN Production ON Production.ProductionID = MediaEntry.ProductionID +LEFT JOIN Category ON Category.CategoryID = MediaEntry.CategoryID +LEFT JOIN ContentPage ON ContentPage.EntryID = MediaEntry.EntryID +LEFT JOIN Comment ON Comment.PageID = ContentPage.PageID +LEFT JOIN Thumbnail ON Thumbnail.EntryID = MediaEntry.EntryID +LEFT JOIN VideoEntry ON VideoEntry.EntryID = MediaEntry.EntryID +LEFT JOIN AudioEntry ON AudioEntry.EntryID = MediaEntry.EntryID +LEFT JOIN ImageEntry ON ImageEntry.EntryID = MediaEntry.EntryID +WHERE MediaEntry.EntryID = 1 \ No newline at end of file diff --git a/SQL/queries/query 4.sql b/SQL/queries/query 4.sql new file mode 100644 index 0000000..1c309d7 --- /dev/null +++ b/SQL/queries/query 4.sql @@ -0,0 +1,11 @@ +SELECT Title, EntryDescription, UploadDate, ProductionName, CategoryName, VideoEntry.VideoFileName, VideoPreview.VideoFileName, AudioEntry.AudioFileName, AudioPreview.AudioFileName, ImageFileName +FROM MediaEntry +LEFT JOIN Production ON Production.ProductionID = MediaEntry.ProductionID +LEFT JOIN Category ON Category.CategoryID = MediaEntry.CategoryID +LEFT JOIN VideoEntry ON VideoEntry.EntryID = MediaEntry.EntryID +--Include previews +LEFT JOIN VideoPreview ON VideoPreview.VideoID = VideoEntry.VideoID +LEFT JOIN AudioEntry ON AudioEntry.EntryID = MediaEntry.EntryID +LEFT JOIN AudioPreview ON AudioPreview.AudioID = AudioEntry.AudioID +LEFT JOIN ImageEntry ON ImageEntry.EntryID = MediaEntry.EntryID +WHERE MediaEntry.UserID = 1 \ No newline at end of file diff --git a/SQL/queries/query 5.sql b/SQL/queries/query 5.sql new file mode 100644 index 0000000..e356d04 --- /dev/null +++ b/SQL/queries/query 5.sql @@ -0,0 +1,12 @@ +SELECT Title, EntryDescription, UploadDate, ProductionName, CategoryName, VideoEntry.VideoFileName, VideoPreview.VideoFileName AS VideoPreviewName, AudioEntry.AudioFileName, AudioPreview.AudioFileName AS AudioPreviewName, ImageFileName, UserName +FROM MediaEntry +LEFT JOIN Users ON Users.UserID = MediaEntry.UserID +LEFT JOIN Production ON Production.ProductionID = MediaEntry.ProductionID +LEFT JOIN Category ON Category.CategoryID = MediaEntry.CategoryID +LEFT JOIN VideoEntry ON VideoEntry.EntryID = MediaEntry.EntryID +--Include previews +LEFT JOIN VideoPreview ON VideoPreview.VideoID = VideoEntry.VideoID +LEFT JOIN AudioEntry ON AudioEntry.EntryID = MediaEntry.EntryID +LEFT JOIN AudioPreview ON AudioPreview.AudioID = AudioEntry.AudioID +LEFT JOIN ImageEntry ON ImageEntry.EntryID = MediaEntry.EntryID +WHERE MediaEntry.UploadDate BETWEEN '2018-09-10 02:33:13' AND '2018-09-10 12:52:00' \ No newline at end of file diff --git a/SQL/views/Media.sql b/SQL/views/Media.sql new file mode 100644 index 0000000..28f6f67 --- /dev/null +++ b/SQL/views/Media.sql @@ -0,0 +1,4 @@ +SELECT +FROM dbo.MediaEntry INNER JOIN + dbo.Thumbnail ON dbo.MediaEntry.EntryID = dbo.Thumbnail.EntryID INNER JOIN + dbo.Category ON dbo.MediaEntry.CategoryID = dbo.Category.CategoryID \ No newline at end of file diff --git a/SQL/views/Production Entries.sql b/SQL/views/Production Entries.sql new file mode 100644 index 0000000..a65226a --- /dev/null +++ b/SQL/views/Production Entries.sql @@ -0,0 +1,4 @@ +SELECT dbo.MediaEntry.EntryID, dbo.Users.UserID, dbo.Users.UserName, dbo.Production.ProductionName +FROM dbo.Users INNER JOIN + dbo.MediaEntry ON dbo.Users.UserID = dbo.MediaEntry.UserID INNER JOIN + dbo.Production ON dbo.MediaEntry.ProductionID = dbo.Production.ProductionID \ No newline at end of file diff --git a/SQL/views/Users.sql b/SQL/views/Users.sql new file mode 100644 index 0000000..e4b48c2 --- /dev/null +++ b/SQL/views/Users.sql @@ -0,0 +1,5 @@ +SELECT dbo.Roles.RoleName, dbo.Users.LikeCount, dbo.Users.UserDescription, dbo.Users.UserName, dbo.ProfilePicture.PictureFileName, dbo.ProfilePicture.Height, dbo.ProfilePicture.Width +FROM dbo.Roles INNER JOIN + dbo.RoleAllocation ON dbo.Roles.RoleID = dbo.RoleAllocation.RoleID INNER JOIN + dbo.Users ON dbo.RoleAllocation.UserID = dbo.Users.UserID INNER JOIN + dbo.ProfilePicture ON dbo.Users.UserID = dbo.ProfilePicture.UserID \ No newline at end of file