USE [master]
GO
/****** Object:  Database [BookShop]    Script Date: 09/15/2009 18:36:39 ******/
CREATE DATABASE [BookShop] ON  PRIMARY 
( NAME = N'BookShop', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\BookShop.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'BookShop_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\BookShop_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [BookShop] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [BookShop].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [BookShop] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [BookShop] SET ANSI_NULLS OFF
GO
ALTER DATABASE [BookShop] SET ANSI_PADDING OFF
GO
ALTER DATABASE [BookShop] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [BookShop] SET ARITHABORT OFF
GO
ALTER DATABASE [BookShop] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [BookShop] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [BookShop] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [BookShop] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [BookShop] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [BookShop] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [BookShop] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [BookShop] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [BookShop] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [BookShop] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [BookShop] SET  DISABLE_BROKER
GO
ALTER DATABASE [BookShop] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [BookShop] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [BookShop] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [BookShop] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [BookShop] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [BookShop] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [BookShop] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [BookShop] SET  READ_WRITE
GO
ALTER DATABASE [BookShop] SET RECOVERY FULL
GO
ALTER DATABASE [BookShop] SET  MULTI_USER
GO
ALTER DATABASE [BookShop] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [BookShop] SET DB_CHAINING OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'BookShop', N'ON'
GO
USE [BookShop]
GO
/****** Object:  ForeignKey [FK_Book_Category]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[Book] DROP CONSTRAINT [FK_Book_Category]
GO
/****** Object:  ForeignKey [FK_AuthorBook_Author]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[AuthorBook] DROP CONSTRAINT [FK_AuthorBook_Author]
GO
/****** Object:  ForeignKey [FK_AuthorBook_Book]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[AuthorBook] DROP CONSTRAINT [FK_AuthorBook_Book]
GO
/****** Object:  Table [dbo].[AuthorBook]    Script Date: 09/15/2009 18:36:39 ******/
DROP TABLE [dbo].[AuthorBook]
GO
/****** Object:  Table [dbo].[Book]    Script Date: 09/15/2009 18:36:39 ******/
DROP TABLE [dbo].[Book]
GO
/****** Object:  Table [dbo].[Category]    Script Date: 09/15/2009 18:36:39 ******/
DROP TABLE [dbo].[Category]
GO
/****** Object:  Table [dbo].[Author]    Script Date: 09/15/2009 18:36:39 ******/
DROP TABLE [dbo].[Author]
GO
/****** Object:  Table [dbo].[Author]    Script Date: 09/15/2009 18:36:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Author](
	[AuthorId] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[BirthDate] [date] NOT NULL,
 CONSTRAINT [PK_Author] PRIMARY KEY CLUSTERED 
(
	[AuthorId] 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: 09/15/2009 18:36:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Category](
	[CategoryId] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Category] 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
SET IDENTITY_INSERT [dbo].[Category] ON
INSERT [dbo].[Category] ([CategoryId], [Name]) VALUES (1, N'Computer Science')
INSERT [dbo].[Category] ([CategoryId], [Name]) VALUES (2, N'Novel')
INSERT [dbo].[Category] ([CategoryId], [Name]) VALUES (3, N'Biographi')
SET IDENTITY_INSERT [dbo].[Category] OFF
/****** Object:  Table [dbo].[Book]    Script Date: 09/15/2009 18:36:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Book](
	[BookId] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[ListPrice] [money] NOT NULL,
	[CategoryId] [int] NOT NULL,
	[PageSize] [smallint] NOT NULL,
 CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED 
(
	[BookId] 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
SET IDENTITY_INSERT [dbo].[Book] ON
INSERT [dbo].[Book] ([BookId], [Name], [ListPrice], [CategoryId], [PageSize]) VALUES (1, N'Programming C# 4.0', 42.0000, 1, 1000)
INSERT [dbo].[Book] ([BookId], [Name], [ListPrice], [CategoryId], [PageSize]) VALUES (2, N'Pro WCF 3.5 First Edition', 41.0000, 1, 500)
INSERT [dbo].[Book] ([BookId], [Name], [ListPrice], [CategoryId], [PageSize]) VALUES (3, N'The Last Lecture', 15.0000, 2, 350)
SET IDENTITY_INSERT [dbo].[Book] OFF
/****** Object:  Table [dbo].[AuthorBook]    Script Date: 09/15/2009 18:36:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AuthorBook](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AuthorId] [int] NOT NULL,
	[BookId] [int] NOT NULL,
 CONSTRAINT [PK_AuthorBook] 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:  ForeignKey [FK_Book_Category]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_Category] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Category] ([CategoryId])
GO
ALTER TABLE [dbo].[Book] CHECK CONSTRAINT [FK_Book_Category]
GO
/****** Object:  ForeignKey [FK_AuthorBook_Author]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[AuthorBook]  WITH CHECK ADD  CONSTRAINT [FK_AuthorBook_Author] FOREIGN KEY([AuthorId])
REFERENCES [dbo].[Author] ([AuthorId])
GO
ALTER TABLE [dbo].[AuthorBook] CHECK CONSTRAINT [FK_AuthorBook_Author]
GO
/****** Object:  ForeignKey [FK_AuthorBook_Book]    Script Date: 09/15/2009 18:36:39 ******/
ALTER TABLE [dbo].[AuthorBook]  WITH CHECK ADD  CONSTRAINT [FK_AuthorBook_Book] FOREIGN KEY([BookId])
REFERENCES [dbo].[Book] ([BookId])
GO
ALTER TABLE [dbo].[AuthorBook] CHECK CONSTRAINT [FK_AuthorBook_Book]
GO
