Listing A
CREATE TABLE [dbo].[AVAILABILITY] (
       [AVAILABILITY_ID] [int] IDENTITY (1, 1) NOT NULL ,
       [AVAILABILITY_NAME] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
 
 
CREATE TABLE [dbo].[BOOK] (
       [BOOK_ID] [int] IDENTITY (1, 1) NOT NULL ,
       [BOOK_NAME] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
       [AUTHOR] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
       [PRICE] [smallmoney] NOT NULL ,
       [AVAILABILITY_ID] [int] NOT NULL
) ON [PRIMARY]
GO
 
 
CREATE TABLE [dbo].[CLIENT] (
       [CLIENT_ID] [int] IDENTITY (1, 1) NOT NULL ,
       [CLIENT_NAME] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
       [WS_TOKEN] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
 
 
CREATE TABLE [dbo].[ORDER] (
       [ORDER_ID] [int] NOT NULL ,
       [ORDER_STATUS] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
       [CLIENT_ID] [int] NOT NULL ,
       [CREATION_DATE] [datetime] NOT NULL
) ON [PRIMARY]
GO
 
 
CREATE TABLE [dbo].[ORDER_BOOK_REL] (
       [ORDER_ID] [int] NOT NULL ,
       [BOOK_ID] [int] NOT NULL
) ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[AVAILABILITY] WITH NOCHECK ADD
       CONSTRAINT [AVAILABILITY_PK] PRIMARY KEY  CLUSTERED
       (
              [AVAILABILITY_ID]
       )  ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[BOOK] WITH NOCHECK ADD
       CONSTRAINT [BOOK_PK] PRIMARY KEY  CLUSTERED
       (
              [BOOK_ID]
       )  ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[CLIENT] WITH NOCHECK ADD
       CONSTRAINT [CLIENT_PK] PRIMARY KEY  CLUSTERED
       (
              [CLIENT_ID]
       )  ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[ORDER] WITH NOCHECK ADD
       CONSTRAINT [ORDER_PK] PRIMARY KEY  CLUSTERED
       (
              [ORDER_ID]
       )  ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[ORDER_BOOK_REL] WITH NOCHECK ADD
       CONSTRAINT [ORDER_BOOK_REL_PK] PRIMARY KEY  CLUSTERED
       (
              [ORDER_ID],
             [BOOK_ID]
       )  ON [PRIMARY]
GO
 
 
ALTER TABLE [dbo].[ORDER] WITH NOCHECK ADD
       CONSTRAINT [DF_ORDER_CREATION_DATE] DEFAULT (getdate()) FOR [CREATION_DATE]
GO
 
 
ALTER TABLE [dbo].[BOOK] ADD
       CONSTRAINT [AVAILABILITY_BOOK_FK1] FOREIGN KEY
       (
              [AVAILABILITY_ID]
       ) REFERENCES [dbo].[AVAILABILITY] (
              [AVAILABILITY_ID]
       )
GO
 
 
ALTER TABLE [dbo].[ORDER] ADD
       CONSTRAINT [CLIENT_ORDER_FK1] FOREIGN KEY
       (
              [CLIENT_ID]
       ) REFERENCES [dbo].[CLIENT] (
              [CLIENT_ID]
       )
GO
 
 
ALTER TABLE [dbo].[ORDER_BOOK_REL] ADD
       CONSTRAINT [BOOK_ORDER_BOOK_REL_FK1] FOREIGN KEY
       (
              [BOOK_ID]
       ) REFERENCES [dbo].[BOOK] (
              [BOOK_ID]
       ),
       CONSTRAINT [ORDER_ORDER_BOOK_REL_FK1] FOREIGN KEY
       (
              [ORDER_ID]
       ) REFERENCES [dbo].[ORDER] (
              [ORDER_ID]
       )
GO