КАТЕГОРИИ: Архитектура-(3434)Астрономия-(809)Биология-(7483)Биотехнологии-(1457)Военное дело-(14632)Высокие технологии-(1363)География-(913)Геология-(1438)Государство-(451)Демография-(1065)Дом-(47672)Журналистика и СМИ-(912)Изобретательство-(14524)Иностранные языки-(4268)Информатика-(17799)Искусство-(1338)История-(13644)Компьютеры-(11121)Косметика-(55)Кулинария-(373)Культура-(8427)Лингвистика-(374)Литература-(1642)Маркетинг-(23702)Математика-(16968)Машиностроение-(1700)Медицина-(12668)Менеджмент-(24684)Механика-(15423)Науковедение-(506)Образование-(11852)Охрана труда-(3308)Педагогика-(5571)Полиграфия-(1312)Политика-(7869)Право-(5454)Приборостроение-(1369)Программирование-(2801)Производство-(97182)Промышленность-(8706)Психология-(18388)Религия-(3217)Связь-(10668)Сельское хозяйство-(299)Социология-(6455)Спорт-(42831)Строительство-(4793)Торговля-(5050)Транспорт-(2929)Туризм-(1568)Физика-(3942)Философия-(17015)Финансы-(26596)Химия-(22929)Экология-(12095)Экономика-(9961)Электроника-(8441)Электротехника-(4623)Энергетика-(12629)Юриспруденция-(1492)Ядерная техника-(1748) |
Скрипт создания базы данных
Полный скрипт создания БД, таблиц, индексов и ограничений Для ограничения CK_RatingRange Для ограничения CK_Size Для ограничения CK_BooksRatingRange Для ограничения CK_DataFirstPublRange Список контрольных тестов для проверки корректности данных в таблицах INSERT INTO Books (BookNameId, PublisherId, ISBN, DataFirstPubl) VALUES (1, 1, '9999999999999', '1800-01-01') INSERT INTO Books (BookNameId, PublisherId, ISBN, Rating) VALUES (1, 1, '9999999999999', 12.00) Для ограничения CK_ISBN_MASK INSERT INTO Books (BookNameId, PublisherId, ISBN) VALUES (1, 1, '999999999h999') INSERT INTO FileStat (BookId, BookType, Size) VALUES (1, 1, -4.0) INSERT INTO UserHistory (FileBookId, UserName, Data, Rating) VALUES (1, 'ddd', '2000-01-01', 12.00)
USE [master] GO
/****** Object: Database [ForLabs] Script Date: 10/01/2012 10:17:40 ******/ CREATE DATABASE [ForLabs] ON PRIMARY (NAME = N'ForLabs', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\ForLabs.mdf', SIZE = 5120KB, MAXSIZE = 524288KB, FILEGROWTH = 20480KB) LOG ON (NAME = N'ForLabs_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\ForLabs_log.ldf', SIZE = 2048KB, MAXSIZE = 524288KB, FILEGROWTH = 15%) GO
ALTER DATABASE [ForLabs] SET COMPATIBILITY_LEVEL = 100 GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')) begin EXEC [ForLabs].[dbo].[sp_fulltext_database] @action = 'enable' end GO
ALTER DATABASE [ForLabs] SET ANSI_NULL_DEFAULT OFF GO
ALTER DATABASE [ForLabs] SET ANSI_NULLS OFF GO
ALTER DATABASE [ForLabs] SET ANSI_PADDING OFF GO
ALTER DATABASE [ForLabs] SET ANSI_WARNINGS OFF GO
ALTER DATABASE [ForLabs] SET ARITHABORT OFF GO
ALTER DATABASE [ForLabs] SET AUTO_CLOSE OFF GO
ALTER DATABASE [ForLabs] SET AUTO_CREATE_STATISTICS ON GO
ALTER DATABASE [ForLabs] SET AUTO_SHRINK OFF GO
ALTER DATABASE [ForLabs] SET AUTO_UPDATE_STATISTICS ON GO
ALTER DATABASE [ForLabs] SET CURSOR_CLOSE_ON_COMMIT OFF GO
ALTER DATABASE [ForLabs] SET CURSOR_DEFAULT GLOBAL GO
ALTER DATABASE [ForLabs] SET CONCAT_NULL_YIELDS_NULL OFF GO
ALTER DATABASE [ForLabs] SET NUMERIC_ROUNDABORT OFF GO
ALTER DATABASE [ForLabs] SET QUOTED_IDENTIFIER OFF GO
ALTER DATABASE [ForLabs] SET RECURSIVE_TRIGGERS OFF GO
ALTER DATABASE [ForLabs] SET DISABLE_BROKER GO
ALTER DATABASE [ForLabs] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GO
ALTER DATABASE [ForLabs] SET DATE_CORRELATION_OPTIMIZATION OFF GO
ALTER DATABASE [ForLabs] SET TRUSTWORTHY OFF GO
ALTER DATABASE [ForLabs] SET ALLOW_SNAPSHOT_ISOLATION OFF GO
ALTER DATABASE [ForLabs] SET PARAMETERIZATION SIMPLE GO
ALTER DATABASE [ForLabs] SET READ_COMMITTED_SNAPSHOT OFF GO
ALTER DATABASE [ForLabs] SET HONOR_BROKER_PRIORITY OFF GO
ALTER DATABASE [ForLabs] SET READ_WRITE GO
ALTER DATABASE [ForLabs] SET RECOVERY SIMPLE GO
ALTER DATABASE [ForLabs] SET MULTI_USER GO
ALTER DATABASE [ForLabs] SET PAGE_VERIFY CHECKSUM GO
ALTER DATABASE [ForLabs] SET DB_CHAINING OFF GO
Скрипт создания таблиц, индексов и ограничений USE [ForLabs] GO /****** Object: Table [dbo].[Users] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Users]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](20) NOT NULL, [Pass] [varchar](20) NOT NULL, [EMail] [varchar](40) NOT NULL, CONSTRAINT [PK_Id] 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], CONSTRAINT [UQ__Users__737584F667DE6983] UNIQUE NONCLUSTERED ( [Name] 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__7614F5F66501FCD8] UNIQUE NONCLUSTERED ( [EMail] 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 ANSI_PADDING OFF GO /****** Object: Table [dbo].[Publisher] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Publisher]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](40) NOT NULL, CONSTRAINT [PK_pId] 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 SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[Genre] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Genre]( [Id] [tinyint] IDENTITY(1,1) NOT NULL, [Genre] [varchar](30) NOT NULL, CONSTRAINT [PK_gId] 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 SET ANSI_PADDING OFF GO /****** Object: Table [dbo].[Authors] Script Date: 10/01/2012 10:22:14 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Authors]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](40) NOT NULL, CONSTRAINT [PK_aId] 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 SET ANSI_PADDING OFF GO CREATE NONCLUSTERED INDEX [I_Authors_Author] ON [dbo].[Authors] ( [Name] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[BookType] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[BookType]( [Id] [tinyint] IDENTITY(1,1) NOT NULL, [BookType] [varchar](5) NOT NULL, CONSTRAINT [PK_btId] 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 SET ANSI_PADDING OFF GO CREATE NONCLUSTERED INDEX [I_BookType_Type] ON [dbo].[BookType] ( [BookType] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[BooksTitle] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[BooksTitle]( [Id] [int] IDENTITY(1,1) NOT NULL, [Title] [varchar](70) NOT NULL, CONSTRAINT [PK_btiId] 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 SET ANSI_PADDING OFF GO CREATE NONCLUSTERED INDEX [I_BooksTitle_Title] ON [dbo].[BooksTitle] ( [Title] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[Books] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Books]( [Id] [int] IDENTITY(1,1) NOT NULL, [BookNameId] [int] NOT NULL, [PublisherId] [int] NOT NULL, [Edition] [tinyint] NULL, [DataFirstPubl] [datetime] NOT NULL, [Rating] [numeric](2, 2) NULL, [ISBN] [nchar](13) NOT NULL, [UDK] [varchar](20) NULL, CONSTRAINT [PK_bId] 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 SET ANSI_PADDING OFF GO CREATE NONCLUSTERED INDEX [I_Books_BookNameId] ON [dbo].[Books] ( [BookNameId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE NONCLUSTERED INDEX [I_Books_PublisherId] ON [dbo].[Books] ( [PublisherId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE NONCLUSTERED INDEX [I_Books_Rating] ON [dbo].[Books] ( [Rating] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[RelationBooksAndGenre] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[RelationBooksAndGenre]( [Id] [int] IDENTITY(1,1) NOT NULL, [GenreId] [tinyint] NOT NULL, [BooksId] [int] NOT NULL, CONSTRAINT [PK_rbgId] 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 CREATE NONCLUSTERED INDEX [I_RelationBooksAndGenre_BooksId] ON [dbo].[RelationBooksAndGenre] ( [BooksId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE NONCLUSTERED INDEX [I_RelationBooksAndGenre_GenreId] ON [dbo].[RelationBooksAndGenre] ( [GenreId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[RelationBooksAndAuthor] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[RelationBooksAndAuthor]( [Id] [int] IDENTITY(1,1) NOT NULL, [AuthorId] [int] NOT NULL, [BooksId] [int] NOT NULL, CONSTRAINT [PK_rbaId] 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 CREATE NONCLUSTERED INDEX [I_RelationBooksAndAuthor_AuthorId] ON [dbo].[RelationBooksAndAuthor] ( [AuthorId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE NONCLUSTERED INDEX [I_RelationBooksAndAuthor_BooksId] ON [dbo].[RelationBooksAndAuthor] ( [BooksId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[FileStat] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[FileStat]( [Id] [int] IDENTITY(1,1) NOT NULL, [BookId] [int] NOT NULL, [BookType] [tinyint] NOT NULL, [Downloads] [int] NULL, [Size] [float] NULL, [BookFileLink] [varchar](256) NULL, CONSTRAINT [PK_fsId] 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 SET ANSI_PADDING OFF GO CREATE NONCLUSTERED INDEX [I_FileStat_BookId] ON [dbo].[FileStat] ( [BookId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO CREATE NONCLUSTERED INDEX [I_FileStat_BookType] ON [dbo].[FileStat] ( [BookType] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] GO /****** Object: Table [dbo].[UserHistory] Script Date: 10/01/2012 10:22:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[UserHistory]( [Id] [int] IDENTITY(1,1) NOT NULL, [UserName] [varchar](20) NOT NULL, [FileBookId] [int] NOT NULL, [Data] [datetime] NOT NULL, [Rating] [float] NULL, CONSTRAINT [PK_uhId] 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 SET ANSI_PADDING OFF GO /****** Object: Check [CK_BooksRatingRange] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[Books] WITH CHECK ADD CONSTRAINT [CK_BooksRatingRange] CHECK (([Rating]>(0) AND [Rating]<(11))) GO ALTER TABLE [dbo].[Books] CHECK CONSTRAINT [CK_BooksRatingRange] GO /****** Object: Check [CK_DataFirstPublRange] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[Books] WITH CHECK ADD CONSTRAINT [CK_DataFirstPublRange] CHECK (([DataFirstPubl]>'01-01-1850' AND [DataFirstPubl]<=getdate())) GO ALTER TABLE [dbo].[Books] CHECK CONSTRAINT [CK_DataFirstPublRange] GO /****** Object: Check [CK_ISBN_MASK] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[Books] WITH CHECK ADD CONSTRAINT [CK_ISBN_MASK] CHECK (([ISBN] like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]')) GO ALTER TABLE [dbo].[Books] CHECK CONSTRAINT [CK_ISBN_MASK] GO /****** Object: Check [CK_Size] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[FileStat] WITH CHECK ADD CONSTRAINT [CK_Size] CHECK (([Size]>(0))) GO ALTER TABLE [dbo].[FileStat] CHECK CONSTRAINT [CK_Size] GO /****** Object: Check [CK_RatingRange] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[UserHistory] WITH CHECK ADD CONSTRAINT [CK_RatingRange] CHECK (([Rating]>(0) AND [Rating]<(11))) GO ALTER TABLE [dbo].[UserHistory] CHECK CONSTRAINT [CK_RatingRange] GO /****** Object: ForeignKey [FK_BookNameId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[Books] WITH CHECK ADD CONSTRAINT [FK_BookNameId] FOREIGN KEY([BookNameId]) REFERENCES [dbo].[BooksTitle] ([Id]) GO ALTER TABLE [dbo].[Books] CHECK CONSTRAINT [FK_BookNameId] GO /****** Object: ForeignKey [FK_PublisherId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[Books] WITH CHECK ADD CONSTRAINT [FK_PublisherId] FOREIGN KEY([PublisherId]) REFERENCES [dbo].[Publisher] ([Id]) GO ALTER TABLE [dbo].[Books] CHECK CONSTRAINT [FK_PublisherId] GO /****** Object: ForeignKey [FK_BookId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[FileStat] WITH CHECK ADD CONSTRAINT [FK_BookId] FOREIGN KEY([BookId]) REFERENCES [dbo].[Books] ([Id]) GO ALTER TABLE [dbo].[FileStat] CHECK CONSTRAINT [FK_BookId] GO /****** Object: ForeignKey [FK_BookType] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[FileStat] WITH CHECK ADD CONSTRAINT [FK_BookType] FOREIGN KEY([BookType]) REFERENCES [dbo].[BookType] ([Id]) GO ALTER TABLE [dbo].[FileStat] CHECK CONSTRAINT [FK_BookType] GO /****** Object: ForeignKey [FK_AuthorId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[RelationBooksAndAuthor] WITH CHECK ADD CONSTRAINT [FK_AuthorId] FOREIGN KEY([AuthorId]) REFERENCES [dbo].[Authors] ([Id]) ON DELETE CASCADE GO ALTER TABLE [dbo].[RelationBooksAndAuthor] CHECK CONSTRAINT [FK_AuthorId] GO /****** Object: ForeignKey [FK_BooksId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[RelationBooksAndAuthor] WITH CHECK ADD CONSTRAINT [FK_BooksId] FOREIGN KEY([BooksId]) REFERENCES [dbo].[Books] ([Id]) ON DELETE CASCADE GO ALTER TABLE [dbo].[RelationBooksAndAuthor] CHECK CONSTRAINT [FK_BooksId] GO /****** Object: ForeignKey [FK_GBooksId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[RelationBooksAndGenre] WITH CHECK ADD CONSTRAINT [FK_GBooksId] FOREIGN KEY([BooksId]) REFERENCES [dbo].[Books] ([Id]) ON DELETE CASCADE GO ALTER TABLE [dbo].[RelationBooksAndGenre] CHECK CONSTRAINT [FK_GBooksId] GO /****** Object: ForeignKey [FK_GenreId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[RelationBooksAndGenre] WITH CHECK ADD CONSTRAINT [FK_GenreId] FOREIGN KEY([GenreId]) REFERENCES [dbo].[Genre] ([Id]) ON DELETE CASCADE GO ALTER TABLE [dbo].[RelationBooksAndGenre] CHECK CONSTRAINT [FK_GenreId] GO /****** Object: ForeignKey [FK_FileBookId] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[UserHistory] WITH CHECK ADD CONSTRAINT [FK_FileBookId] FOREIGN KEY([FileBookId]) REFERENCES [dbo].[FileStat] ([Id]) GO ALTER TABLE [dbo].[UserHistory] CHECK CONSTRAINT [FK_FileBookId] GO /****** Object: ForeignKey [FK_UserName] Script Date: 10/01/2012 10:22:15 ******/ ALTER TABLE [dbo].[UserHistory] WITH CHECK ADD CONSTRAINT [FK_UserName] FOREIGN KEY([UserName]) REFERENCES [dbo].[Users] ([Name]) ON DELETE CASCADE GO ALTER TABLE [dbo].[UserHistory] CHECK CONSTRAINT [FK_UserName] GO
Дата добавления: 2015-05-09; Просмотров: 508; Нарушение авторских прав?; Мы поможем в написании вашей работы! Нам важно ваше мнение! Был ли полезен опубликованный материал? Да | Нет |