SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CARISUBE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CARISUBE](
	[CARISUBEID] [int] IDENTITY(1,1) NOT NULL,
	[CARIID] [int] NULL,
	[SUBEID] [int] NULL,
 CONSTRAINT [PK_CARISUBE] PRIMARY KEY CLUSTERED 
(
	[CARISUBEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CARISUBE_CARI]') AND parent_object_id = OBJECT_ID(N'[dbo].[CARISUBE]'))
ALTER TABLE [dbo].[CARISUBE]  WITH CHECK ADD  CONSTRAINT [FK_CARISUBE_CARI] FOREIGN KEY([CARIID])
REFERENCES [dbo].[CARI] ([CARIID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CARISUBE_CARI]') AND parent_object_id = OBJECT_ID(N'[dbo].[CARISUBE]'))
ALTER TABLE [dbo].[CARISUBE] CHECK CONSTRAINT [FK_CARISUBE_CARI]
GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CARISUBE_SUBELER]') AND parent_object_id = OBJECT_ID(N'[dbo].[CARISUBE]'))
ALTER TABLE [dbo].[CARISUBE]  WITH CHECK ADD  CONSTRAINT [FK_CARISUBE_SUBELER] FOREIGN KEY([SUBEID])
REFERENCES [dbo].[SUBELER] ([SUBEID])
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CARISUBE_SUBELER]') AND parent_object_id = OBJECT_ID(N'[dbo].[CARISUBE]'))
ALTER TABLE [dbo].[CARISUBE] CHECK CONSTRAINT [FK_CARISUBE_SUBELER]
GO