2 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Author]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
3 drop table [dbo].[Author]
\r
6 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Blog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
7 drop table [dbo].[Blog]
\r
10 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Post]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
\r
11 drop table [dbo].[Post]
\r
14 CREATE TABLE [dbo].[Author] (
\r
15 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
16 [name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
\r
17 [login] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
\r
18 [password] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
\r
22 CREATE TABLE [dbo].[Blog] (
\r
23 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
24 [name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
\r
25 [description] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
\r
26 [theme] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
\r
27 [author_id] [int] NOT NULL
\r
31 CREATE TABLE [dbo].[Post] (
\r
32 [id] [int] IDENTITY (1, 1) NOT NULL ,
\r
33 [title] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
\r
34 [contents] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
\r
35 [date] [smalldatetime] NOT NULL ,
\r
36 [blog_id] [int] NOT NULL
\r
37 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
\r
40 ALTER TABLE [dbo].[Author] WITH NOCHECK ADD
\r
41 CONSTRAINT [PK_Author] PRIMARY KEY CLUSTERED
\r
47 ALTER TABLE [dbo].[Blog] WITH NOCHECK ADD
\r
48 CONSTRAINT [PK_Blog] PRIMARY KEY CLUSTERED
\r
54 ALTER TABLE [dbo].[Post] WITH NOCHECK ADD
\r
55 CONSTRAINT [PK_post] PRIMARY KEY CLUSTERED
\r