USE [master]
GO
/****** Object:  Database [MicroBloggingDb]    Script Date: 12/30/2015 12:06:49 PM ******/
CREATE DATABASE [MicroBloggingDb]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'MicroBloggingDb', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\MicroBloggingDb.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'MicroBloggingDb_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\MicroBloggingDb_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [MicroBloggingDb] SET COMPATIBILITY_LEVEL = 120
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [MicroBloggingDb].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [MicroBloggingDb] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET ARITHABORT OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [MicroBloggingDb] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [MicroBloggingDb] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET  DISABLE_BROKER 
GO
ALTER DATABASE [MicroBloggingDb] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [MicroBloggingDb] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [MicroBloggingDb] SET  MULTI_USER 
GO
ALTER DATABASE [MicroBloggingDb] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [MicroBloggingDb] SET DB_CHAINING OFF 
GO
ALTER DATABASE [MicroBloggingDb] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [MicroBloggingDb] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
ALTER DATABASE [MicroBloggingDb] SET DELAYED_DURABILITY = DISABLED 
GO
USE [MicroBloggingDb]
GO
/****** Object:  Table [dbo].[follows]    Script Date: 12/30/2015 12:06:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[follows](
	[Id] [int] IDENTITY(0,1) NOT NULL,
	[source] [int] NOT NULL,
	[target] [int] NULL,
 CONSTRAINT [PK_follows] 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].[posts]    Script Date: 12/30/2015 12:06:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[posts](
	[id] [int] IDENTITY(0,1) NOT NULL,
	[text] [nchar](200) NULL,
	[userId] [int] NULL,
	[public] [bit] NOT NULL,
	[date] [datetime] NOT NULL,
	[Picture] [nchar](225) NULL,
 CONSTRAINT [PK_posts] 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].[users]    Script Date: 12/30/2015 12:06:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[users](
	[Id] [int] IDENTITY(0,1) NOT NULL,
	[FullName] [nchar](100) NOT NULL,
	[Username] [nchar](100) NOT NULL,
	[Gender] [nchar](1) NOT NULL,
	[Password] [nchar](100) NOT NULL,
	[Picture] [nchar](100) NULL,
 CONSTRAINT [PK_users] 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],
UNIQUE NONCLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UQ__users__A9D10534E9C4E8B1] UNIQUE NONCLUSTERED 
(
	[Username] 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].[follows]  WITH CHECK ADD  CONSTRAINT [FK_follows_follows] FOREIGN KEY([Id])
REFERENCES [dbo].[follows] ([Id])
GO
ALTER TABLE [dbo].[follows] CHECK CONSTRAINT [FK_follows_follows]
GO
ALTER TABLE [dbo].[follows]  WITH CHECK ADD  CONSTRAINT [FK_follows_follows1] FOREIGN KEY([Id])
REFERENCES [dbo].[follows] ([Id])
GO
ALTER TABLE [dbo].[follows] CHECK CONSTRAINT [FK_follows_follows1]
GO
ALTER TABLE [dbo].[posts]  WITH CHECK ADD  CONSTRAINT [fk_users] FOREIGN KEY([userId])
REFERENCES [dbo].[users] ([Id])
GO
ALTER TABLE [dbo].[posts] CHECK CONSTRAINT [fk_users]
GO
USE [master]
GO
ALTER DATABASE [MicroBloggingDb] SET  READ_WRITE 
GO
