if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__discounts__stor___0F975522]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[discounts] DROP CONSTRAINT FK__discounts__stor___0F975522
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__sales__stor_id__0AD2A005]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[sales] DROP CONSTRAINT FK__sales__stor_id__0AD2A005
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__roysched__title___0DAF0CB0]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[roysched] DROP CONSTRAINT FK__roysched__title___0DAF0CB0
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__sales__title_id__0BC6C43E]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[sales] DROP CONSTRAINT FK__sales__title_id__0BC6C43E
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__titleauth__title__060DEAE8]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[titleauthor] DROP CONSTRAINT FK__titleauth__title__060DEAE8
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[stores]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[stores]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[titleauthor]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[titleauthor]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[titles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[titles]
GO
CREATE TABLE [dbo].[stores] (
[stor_id] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[stor_name] [varchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
[stor_address] [varchar] (40) COLLATE Chinese_PRC_CI_AS NULL ,
[city] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[state] [char] (2) COLLATE Chinese_PRC_CI_AS NULL ,
[zip] [char] (5) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[titleauthor] (
[au_id] [id] NOT NULL ,
[title_id] [tid] NOT NULL ,
[au_ord] [tinyint] NULL ,
[royaltyper] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[titles] (
[title_id] [tid] NOT NULL ,
[title] [varchar] (80) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[type] [char] (12) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[pub_id] [char] (4) COLLATE Chinese_PRC_CI_AS NULL ,
[price] [money] NULL ,
[advance] [money] NULL ,
[royalty] [int] NULL ,
[ytd_sales] [int] NULL ,
[notes] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[pubdate] [datetime] NOT NULL
) ON [PRIMARY]
GO