USE [master]
GO
/****** Object:  Database [ItemMall]    Script Date: 12/20/2015 6:08:58 PM ******/
CREATE DATABASE [ItemMall]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'ItemMall', FILENAME = N'D:\SQL SERVER DATA\SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\ItemMall.mdf' , SIZE = 6144KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'ItemMall_log', FILENAME = N'D:\SQL SERVER DATA\SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\ItemMall_1.ldf' , SIZE = 3456KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [ItemMall] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [ItemMall].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [ItemMall] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [ItemMall] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [ItemMall] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [ItemMall] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [ItemMall] SET ARITHABORT OFF 
GO
ALTER DATABASE [ItemMall] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [ItemMall] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [ItemMall] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [ItemMall] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [ItemMall] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [ItemMall] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [ItemMall] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [ItemMall] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [ItemMall] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [ItemMall] SET  DISABLE_BROKER 
GO
ALTER DATABASE [ItemMall] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [ItemMall] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [ItemMall] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [ItemMall] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [ItemMall] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [ItemMall] SET READ_COMMITTED_SNAPSHOT OFF 
GO
ALTER DATABASE [ItemMall] SET HONOR_BROKER_PRIORITY OFF 
GO
ALTER DATABASE [ItemMall] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [ItemMall] SET  MULTI_USER 
GO
ALTER DATABASE [ItemMall] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [ItemMall] SET DB_CHAINING OFF 
GO
ALTER DATABASE [ItemMall] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO
ALTER DATABASE [ItemMall] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO
ALTER DATABASE [ItemMall] SET DELAYED_DURABILITY = DISABLED 
GO
USE [ItemMall]
GO
/****** Object:  User [Stormy-PC\Administrator]    Script Date: 12/20/2015 6:08:58 PM ******/
CREATE USER [Stormy-PC\Administrator] FOR LOGIN [Stormy-PC\Administrator] WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  User [odinstore]    Script Date: 12/20/2015 6:08:58 PM ******/
CREATE USER [odinstore] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  User [NT AUTHORITY\SYSTEM]    Script Date: 12/20/2015 6:08:58 PM ******/
CREATE USER [NT AUTHORITY\SYSTEM] FOR LOGIN [NT AUTHORITY\SYSTEM] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_accessadmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_securityadmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_backupoperator] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_datareader] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_denydatareader] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_denydatawriter] ADD MEMBER [Stormy-PC\Administrator]
GO
ALTER ROLE [db_owner] ADD MEMBER [odinstore]
GO
ALTER ROLE [db_owner] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_accessadmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_securityadmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_ddladmin] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_backupoperator] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_datareader] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_denydatareader] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
ALTER ROLE [db_denydatawriter] ADD MEMBER [NT AUTHORITY\SYSTEM]
GO
/****** Object:  Table [dbo].[tCats]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tCats](
	[nID] [int] NOT NULL,
	[nCat] [int] NOT NULL,
	[nSubCat] [int] NOT NULL,
	[sName] [nvarchar](500) NOT NULL,
	[nEnabled] [int] NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tItems]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tItems](
	[nID] [int] IDENTITY(1,1) NOT NULL,
	[nGoodsNo] [int] NOT NULL,
	[sName] [nvarchar](500) NOT NULL,
	[nLot] [int] NOT NULL,
	[nIsPackage] [int] NOT NULL,
	[sPackagedItems] [nvarchar](250) NOT NULL CONSTRAINT [DF_tItems_sPackagedItems]  DEFAULT (''),
	[nPrice] [int] NOT NULL,
	[dSaleStart] [datetime] NOT NULL CONSTRAINT [DF_tItems_dSaleStart]  DEFAULT (getdate()),
	[nSaleTime] [int] NOT NULL,
	[nSaleType] [int] NOT NULL CONSTRAINT [DF_tItems_nSaleType]  DEFAULT ('0'),
	[nSaleAmount] [int] NOT NULL,
	[nSaleEnabled] [int] NOT NULL CONSTRAINT [DF_tItems_nSaleEnabled]  DEFAULT ('0'),
	[nGiftable] [int] NOT NULL,
	[nCat] [int] NOT NULL,
	[sDescript] [nvarchar](500) NOT NULL,
	[nEnabled] [int] NOT NULL,
	[nCanBonusPoints] [int] NOT NULL,
	[nIsMiniGameReward] [int] NOT NULL,
	[nMiniGamePercent] [int] NOT NULL CONSTRAINT [DF_tItems_nMiniGamePercent]  DEFAULT ('0'),
	[sSubCatArray] [nvarchar](50) NOT NULL CONSTRAINT [DF_tItems_sSubCatArray]  DEFAULT ('-'),
	[sContents] [nvarchar](900) NOT NULL CONSTRAINT [DF_tItems_sContents]  DEFAULT ('-'),
	[sImg] [nvarchar](500) NOT NULL CONSTRAINT [DF_tItems_sImg]  DEFAULT (N'-'),
	[sUnits] [nvarchar](500) NOT NULL CONSTRAINT [DF_tItems_sUnits]  DEFAULT (N'Unit')
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tLog]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tLog](
	[nID] [int] IDENTITY(1,1) NOT NULL,
	[nType] [int] NOT NULL,
	[nBuyer] [int] NOT NULL,
	[nGoodsNo] [int] NOT NULL,
	[sItemName] [nvarchar](200) NOT NULL,
	[nPrice] [int] NOT NULL,
	[nReceiver] [int] NOT NULL,
	[sIP] [nvarchar](50) NOT NULL,
	[dDate] [datetime] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tMiniGameRewards]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tMiniGameRewards](
	[nID] [int] IDENTITY(1,1) NOT NULL,
	[aGame] [nvarchar](100) NOT NULL,
	[nGoodsNo] [int] NOT NULL,
	[nChance] [int] NOT NULL,
	[nLog] [int] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tMiniGames]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tMiniGames](
	[nGameID] [int] NOT NULL,
	[sGameName] [nvarchar](500) NOT NULL,
	[nPrice] [int] NOT NULL,
	[nEnabled] [int] NOT NULL,
	[sSwfLoc] [nvarchar](500) NOT NULL,
	[nWidth] [int] NOT NULL CONSTRAINT [DF_tMiniGames_nWidth]  DEFAULT ((0)),
	[nHeight] [int] NOT NULL CONSTRAINT [DF_tMiniGames_nHeight]  DEFAULT ((0))
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tMiniGameTransactions]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tMiniGameTransactions](
	[nID] [int] IDENTITY(1,1) NOT NULL,
	[sTransactionID] [nvarchar](100) NOT NULL,
	[nGoodsNo] [int] NOT NULL,
	[nAGID] [int] NOT NULL,
	[dDate] [datetime] NOT NULL,
	[sIP] [nvarchar](50) NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[tPurchaseRewards]    Script Date: 12/20/2015 6:08:58 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tPurchaseRewards](
	[nID] [int] IDENTITY(1,1) NOT NULL,
	[nDollarAmount] [int] NOT NULL,
	[nGoodsNo] [int] NOT NULL,
	[nEnabled] [int] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[tLog] ADD  CONSTRAINT [DF_tLog_dDate]  DEFAULT (getdate()) FOR [dDate]
GO
ALTER TABLE [dbo].[tMiniGameTransactions] ADD  CONSTRAINT [DF_tMiniGameTransactions_dDate]  DEFAULT (getdate()) FOR [dDate]
GO
ALTER TABLE [dbo].[tMiniGameTransactions] ADD  CONSTRAINT [DF_tMiniGameTransactions_sIP]  DEFAULT ('?') FOR [sIP]
GO
USE [master]
GO
ALTER DATABASE [ItemMall] SET  READ_WRITE 
GO
