USE [master]
GO
/****** Object:  Database [MediaLibrary]    Script Date: 14/12/2018 00:13:31 ******/
CREATE DATABASE [MediaLibrary]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'MediaLibrary', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\MediaLibrary.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
 LOG ON 
( NAME = N'MediaLibrary_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\MediaLibrary_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
ALTER DATABASE [MediaLibrary] SET COMPATIBILITY_LEVEL = 140
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MediaLibrary].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MediaLibrary] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [MediaLibrary] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [MediaLibrary] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [MediaLibrary] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [MediaLibrary] SET ARITHABORT OFF 
GO
ALTER DATABASE [MediaLibrary] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [MediaLibrary] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [MediaLibrary] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [MediaLibrary] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [MediaLibrary] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [MediaLibrary] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [MediaLibrary] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [MediaLibrary] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [MediaLibrary] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [MediaLibrary] SET  DISABLE_BROKER 
GO
ALTER DATABASE [MediaLibrary] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [MediaLibrary] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [MediaLibrary] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [MediaLibrary] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [MediaLibrary] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [MediaLibrary] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [MediaLibrary] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [MediaLibrary] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [MediaLibrary] SET  MULTI_USER 
GO
ALTER DATABASE [MediaLibrary] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [MediaLibrary] SET DB_CHAINING OFF 
GO
ALTER DATABASE [MediaLibrary] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [MediaLibrary] SET TARGET_RECOVERY_TIME = 60 SECONDS 
GO
ALTER DATABASE [MediaLibrary] SET DELAYED_DURABILITY = DISABLED 
GO
ALTER DATABASE [MediaLibrary] SET QUERY_STORE = OFF
GO
USE [MediaLibrary]
GO
ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = ON;
GO
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
GO
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
GO
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
GO
USE [MediaLibrary]
GO
/****** Object:  Table [dbo].[AiredTypes]    Script Date: 14/12/2018 00:13:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AiredTypes](
	[AiredTypeID] [int] IDENTITY(1,1) NOT NULL,
	[AiredType] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AiredTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AudioEntry]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AudioEntry](
	[AudioID] [int] IDENTITY(1,1) NOT NULL,
	[EntryID] [int] NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[ReleaseTypeID] [int] NOT NULL,
	[AudioLength] [int] NOT NULL,
	[BitRate] [int] NOT NULL,
	[AudioFileName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AudioID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AudioFileTypes]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AudioFileTypes](
	[FileTypeID] [int] IDENTITY(1,1) NOT NULL,
	[TypeName] [varchar](255) NOT NULL,
	[TypeExtention] [varchar](10) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[FileTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AudioGenre]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AudioGenre](
	[GenreID] [int] IDENTITY(1,1) NOT NULL,
	[GenreName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[GenreID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AudioGenreEntry]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AudioGenreEntry](
	[GenreEntryID] [int] IDENTITY(1,1) NOT NULL,
	[AudioID] [int] NOT NULL,
	[GenreID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[GenreEntryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AudioPreview]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AudioPreview](
	[PreviewID] [int] IDENTITY(1,1) NOT NULL,
	[AudioID] [int] NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[AudioLength] [int] NOT NULL,
	[BitRate] [int] NOT NULL,
	[AudioFileName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[PreviewID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Category]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Category](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Comment]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Comment](
	[CommentID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[PageID] [int] NOT NULL,
	[Content] [text] NOT NULL,
	[ParentComment] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[CommentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ContentPage]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ContentPage](
	[PageID] [int] IDENTITY(1,1) NOT NULL,
	[EntryID] [int] NOT NULL,
	[Likes] [int] NOT NULL,
	[Dislikes] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[PageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ImageEntry]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ImageEntry](
	[ImageID] [int] IDENTITY(1,1) NOT NULL,
	[EntryID] [int] NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[ImageFileName] [varchar](255) NOT NULL,
	[Height] [int] NOT NULL,
	[Width] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ImageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ImageFileTypes]    Script Date: 14/12/2018 00:13:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ImageFileTypes](
	[FileTypeID] [int] IDENTITY(1,1) NOT NULL,
	[FileTypeName] [varchar](255) NOT NULL,
	[FileTypeExtension] [varchar](10) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[FileTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[MediaEntry]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MediaEntry](
	[EntryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryID] [int] NOT NULL,
	[UserID] [int] NOT NULL,
	[ProductionID] [int] NULL,
	[Title] [varchar](255) NOT NULL,
	[EntryDescription] [text] NULL,
	[UploadDate] [datetime] NOT NULL,
	[Premium] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[EntryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Production]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Production](
	[ProductionID] [int] IDENTITY(1,1) NOT NULL,
	[ProductionName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ProductionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ProfilePicture]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProfilePicture](
	[PictureID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[PictureFileName] [varchar](255) NOT NULL,
	[Height] [int] NOT NULL,
	[Width] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[PictureID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ReleaseType]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ReleaseType](
	[ReleaseTypeID] [int] IDENTITY(1,1) NOT NULL,
	[TypeName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ReleaseTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[RoleAllocation]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[RoleAllocation](
	[RoleAllocationID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[RoleAllocationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Roles]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Roles](
	[RoleID] [int] IDENTITY(1,1) NOT NULL,
	[RoleName] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Thumbnail]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Thumbnail](
	[ThumbnailID] [int] IDENTITY(1,1) NOT NULL,
	[EntryID] [int] NOT NULL,
	[ThumbnailFileName] [varchar](255) NOT NULL,
	[Height] [int] NOT NULL,
	[Width] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ThumbnailID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Users]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](25) NOT NULL,
	[LikeCount] [int] NOT NULL,
	[UserDescription] [text] NULL,
PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[VideoEncode]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VideoEncode](
	[EncodeID] [int] IDENTITY(1,1) NOT NULL,
	[EncodeName] [varchar](255) NOT NULL,
	[Width] [int] NOT NULL,
	[Height] [int] NOT NULL,
	[Framerate] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[EncodeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[VideoEntry]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VideoEntry](
	[VideoID] [int] IDENTITY(1,1) NOT NULL,
	[EntryID] [int] NOT NULL,
	[EncodeID] [int] NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[AiredTypeID] [int] NULL,
	[VideoFileName] [varchar](255) NOT NULL,
	[AiredOn] [datetime] NULL,
	[Length] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[VideoID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[VideoFileTypes]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VideoFileTypes](
	[FileTypeID] [int] IDENTITY(1,1) NOT NULL,
	[TypeName] [varchar](255) NOT NULL,
	[TypeExtension] [varchar](10) NOT NULL,
	[Codec] [varchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[FileTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[VideoPreview]    Script Date: 14/12/2018 00:13:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[VideoPreview](
	[PreviewID] [int] IDENTITY(1,1) NOT NULL,
	[VideoID] [int] NOT NULL,
	[EncodeID] [int] NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[VideoFileName] [varchar](255) NOT NULL,
	[AiredOn] [datetime] NULL,
	[Length] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[PreviewID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AudioEntry]  WITH CHECK ADD FOREIGN KEY([EntryID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
ALTER TABLE [dbo].[AudioEntry]  WITH CHECK ADD FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[AudioFileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[AudioEntry]  WITH CHECK ADD FOREIGN KEY([ReleaseTypeID])
REFERENCES [dbo].[ReleaseType] ([ReleaseTypeID])
GO
ALTER TABLE [dbo].[AudioGenreEntry]  WITH CHECK ADD FOREIGN KEY([AudioID])
REFERENCES [dbo].[AudioEntry] ([AudioID])
GO
ALTER TABLE [dbo].[AudioGenreEntry]  WITH CHECK ADD FOREIGN KEY([GenreID])
REFERENCES [dbo].[AudioGenre] ([GenreID])
GO
ALTER TABLE [dbo].[AudioPreview]  WITH CHECK ADD FOREIGN KEY([AudioID])
REFERENCES [dbo].[AudioEntry] ([AudioID])
GO
ALTER TABLE [dbo].[AudioPreview]  WITH CHECK ADD FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[AudioFileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD FOREIGN KEY([PageID])
REFERENCES [dbo].[ContentPage] ([PageID])
GO
ALTER TABLE [dbo].[Comment]  WITH CHECK ADD FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([UserID])
GO
ALTER TABLE [dbo].[ContentPage]  WITH CHECK ADD FOREIGN KEY([EntryID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
ALTER TABLE [dbo].[ImageEntry]  WITH CHECK ADD FOREIGN KEY([EntryID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
ALTER TABLE [dbo].[ImageEntry]  WITH CHECK ADD FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[ImageFileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[MediaEntry]  WITH CHECK ADD FOREIGN KEY([CategoryID])
REFERENCES [dbo].[Category] ([CategoryID])
GO
ALTER TABLE [dbo].[MediaEntry]  WITH CHECK ADD FOREIGN KEY([ProductionID])
REFERENCES [dbo].[Production] ([ProductionID])
GO
ALTER TABLE [dbo].[MediaEntry]  WITH CHECK ADD FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([UserID])
GO
ALTER TABLE [dbo].[ProfilePicture]  WITH CHECK ADD FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([UserID])
GO
ALTER TABLE [dbo].[RoleAllocation]  WITH CHECK ADD FOREIGN KEY([RoleID])
REFERENCES [dbo].[Roles] ([RoleID])
GO
ALTER TABLE [dbo].[RoleAllocation]  WITH CHECK ADD FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([UserID])
GO
ALTER TABLE [dbo].[Thumbnail]  WITH CHECK ADD FOREIGN KEY([EntryID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
ALTER TABLE [dbo].[VideoEntry]  WITH CHECK ADD FOREIGN KEY([AiredTypeID])
REFERENCES [dbo].[AiredTypes] ([AiredTypeID])
GO
ALTER TABLE [dbo].[VideoEntry]  WITH CHECK ADD FOREIGN KEY([EncodeID])
REFERENCES [dbo].[VideoEncode] ([EncodeID])
GO
ALTER TABLE [dbo].[VideoEntry]  WITH CHECK ADD FOREIGN KEY([EntryID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
ALTER TABLE [dbo].[VideoEntry]  WITH CHECK ADD FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[VideoFileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[VideoPreview]  WITH CHECK ADD FOREIGN KEY([EncodeID])
REFERENCES [dbo].[VideoEncode] ([EncodeID])
GO
ALTER TABLE [dbo].[VideoPreview]  WITH CHECK ADD FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[VideoFileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[VideoPreview]  WITH CHECK ADD FOREIGN KEY([VideoID])
REFERENCES [dbo].[MediaEntry] ([EntryID])
GO
USE [master]
GO
ALTER DATABASE [MediaLibrary] SET  READ_WRITE 
GO
