text: USE [master]
  GO
  /****** Object:  Database [RadioStreamerDB]    Script Date: 21.12.2016 14:26:58 ******/
  CREATE DATABASE [RadioStreamerDB]
   CONTAINMENT = NONE
   ON  PRIMARY 
  ( NAME = N'RadioStreamerDB', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\RadioStreamerDB.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
   LOG ON 
  ( NAME = N'RadioStreamerDB_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\RadioStreamerDB_log.ldf' , SIZE = 2048KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
  GO
  ALTER DATABASE [RadioStreamerDB] SET COMPATIBILITY_LEVEL = 110
  GO
  IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
  begin
  EXEC [RadioStreamerDB].[dbo].[sp_fulltext_database] @action = 'enable'
  end
  GO
  ALTER DATABASE [RadioStreamerDB] SET ANSI_NULL_DEFAULT OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET ANSI_NULLS OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET ANSI_PADDING OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET ANSI_WARNINGS OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET ARITHABORT OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET AUTO_CLOSE OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET AUTO_CREATE_STATISTICS ON 
  GO
  ALTER DATABASE [RadioStreamerDB] SET AUTO_SHRINK OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET AUTO_UPDATE_STATISTICS ON 
  GO
  ALTER DATABASE [RadioStreamerDB] SET CURSOR_CLOSE_ON_COMMIT OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET CURSOR_DEFAULT  GLOBAL 
  GO
  ALTER DATABASE [RadioStreamerDB] SET CONCAT_NULL_YIELDS_NULL OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET NUMERIC_ROUNDABORT OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET QUOTED_IDENTIFIER OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET RECURSIVE_TRIGGERS OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET  DISABLE_BROKER 
  GO
  ALTER DATABASE [RadioStreamerDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET DATE_CORRELATION_OPTIMIZATION OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET TRUSTWORTHY OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET PARAMETERIZATION SIMPLE 
  GO
  ALTER DATABASE [RadioStreamerDB] SET READ_COMMITTED_SNAPSHOT OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET HONOR_BROKER_PRIORITY OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET RECOVERY SIMPLE 
  GO
  ALTER DATABASE [RadioStreamerDB] SET  MULTI_USER 
  GO
  ALTER DATABASE [RadioStreamerDB] SET PAGE_VERIFY CHECKSUM  
  GO
  ALTER DATABASE [RadioStreamerDB] SET DB_CHAINING OFF 
  GO
  ALTER DATABASE [RadioStreamerDB] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
  GO
  ALTER DATABASE [RadioStreamerDB] SET TARGET_RECOVERY_TIME = 0 SECONDS 
  GO
  USE [RadioStreamerDB]
  GO
  /****** Object:  Table [dbo].[Channel]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[Channel](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[Name] [nvarchar](255) NOT NULL,
  	[PageUrl] [nvarchar](255) NOT NULL,
  	[StreamUrl] [nvarchar](255) NOT NULL,
   CONSTRAINT [PK_dbo.Channel] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[Favourite]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[Favourite](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[UserId] [bigint] NOT NULL,
  	[ChannelId] [bigint] NOT NULL,
   CONSTRAINT [PK_dbo.Favourite] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[History]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[History](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[UserId] [bigint] NOT NULL,
  	[ChannelId] [bigint] NOT NULL,
  	[StartDate] [datetime2](7) NOT NULL,
  	[EndDate] [datetime2](7) NOT NULL,
  	[Duration] [int] NOT NULL,
   CONSTRAINT [PK_dbo.History] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[Rating]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[Rating](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[UserId] [bigint] NOT NULL,
  	[ChannelId] [bigint] NOT NULL,
  	[Value] [int] NOT NULL,
   CONSTRAINT [PK_dbo.Rating] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[Tag]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[Tag](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[Name] [nvarchar](255) NOT NULL,
   CONSTRAINT [PK_dbo.Tag] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[TagsChannels]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[TagsChannels](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[TagId] [bigint] NOT NULL,
  	[ChannelId] [bigint] NOT NULL,
   CONSTRAINT [PK_dbo.TagsChannels] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[User]    Script Date: 21.12.2016 14:26:58 ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  CREATE TABLE [dbo].[User](
  	[Id] [bigint] IDENTITY(1,1) NOT NULL,
  	[Login] [nvarchar](255) NOT NULL,
  	[Password] [nvarchar](255) NOT NULL,
  	[Salt] [nvarchar](255) NOT NULL,
  	[Email] [nvarchar](255) NOT NULL,
   CONSTRAINT [PK_dbo.User] PRIMARY KEY CLUSTERED 
  (
  	[Id] 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].[Favourite]  WITH CHECK ADD  CONSTRAINT [FK_Favourite_Channels] FOREIGN KEY([ChannelId])
  REFERENCES [dbo].[Channel] ([Id])
  GO
  ALTER TABLE [dbo].[Favourite] CHECK CONSTRAINT [FK_Favourite_Channels]
  GO
  ALTER TABLE [dbo].[Favourite]  WITH CHECK ADD  CONSTRAINT [FK_Favourite_Users] FOREIGN KEY([UserId])
  REFERENCES [dbo].[User] ([Id])
  GO
  ALTER TABLE [dbo].[Favourite] CHECK CONSTRAINT [FK_Favourite_Users]
  GO
  ALTER TABLE [dbo].[History]  WITH CHECK ADD  CONSTRAINT [FK_History_Channels] FOREIGN KEY([ChannelId])
  REFERENCES [dbo].[Channel] ([Id])
  GO
  ALTER TABLE [dbo].[History] CHECK CONSTRAINT [FK_History_Channels]
  GO
  ALTER TABLE [dbo].[History]  WITH CHECK ADD  CONSTRAINT [FK_History_Users] FOREIGN KEY([UserId])
  REFERENCES [dbo].[User] ([Id])
  GO
  ALTER TABLE [dbo].[History] CHECK CONSTRAINT [FK_History_Users]
  GO
  ALTER TABLE [dbo].[Rating]  WITH CHECK ADD  CONSTRAINT [FK_Rating_Channels] FOREIGN KEY([ChannelId])
  REFERENCES [dbo].[Channel] ([Id])
  GO
  ALTER TABLE [dbo].[Rating] CHECK CONSTRAINT [FK_Rating_Channels]
  GO
  ALTER TABLE [dbo].[Rating]  WITH CHECK ADD  CONSTRAINT [FK_Rating_Users] FOREIGN KEY([UserId])
  REFERENCES [dbo].[User] ([Id])
  GO
  ALTER TABLE [dbo].[Rating] CHECK CONSTRAINT [FK_Rating_Users]
  GO
  ALTER TABLE [dbo].[TagsChannels]  WITH CHECK ADD  CONSTRAINT [FK_TagsChannels_Channels] FOREIGN KEY([ChannelId])
  REFERENCES [dbo].[Channel] ([Id])
  GO
  ALTER TABLE [dbo].[TagsChannels] CHECK CONSTRAINT [FK_TagsChannels_Channels]
  GO
  ALTER TABLE [dbo].[TagsChannels]  WITH CHECK ADD  CONSTRAINT [FK_TagsChannels_Tags] FOREIGN KEY([TagId])
  REFERENCES [dbo].[Tag] ([Id])
  GO
  ALTER TABLE [dbo].[TagsChannels] CHECK CONSTRAINT [FK_TagsChannels_Tags]
  GO
  USE [master]
  GO
  ALTER DATABASE [RadioStreamerDB] SET  READ_WRITE 
  GO