USE [DataPRO]
GO

/****** Object:  Table [dbo].[Channels]    Script Date: 3/29/2019 9:32:09 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Channels](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[GroupId] [int] NOT NULL,
	[IsoCode] [nvarchar](50) NOT NULL,
	[IsoChannelName] [nvarchar](255) NOT NULL,
	[UserCode] [nvarchar](50) NOT NULL,
	[UserChannelName] [nvarchar](255) NOT NULL,
	[DASId] [int] NULL,
	[DASChannelIndex] [int] NOT NULL,
	[GroupChannelOrder] [int] NOT NULL,
	[TestSetupOrder] [int] NOT NULL,
	[SensorId] [int] NULL,
	[Disabled] [bit] NOT NULL,
	[LastModified] [datetime] NOT NULL,
	[LastModifiedBy] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_Channels] 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

ALTER TABLE [dbo].[Channels]  WITH NOCHECK ADD  CONSTRAINT [FK_Channels_DASId] FOREIGN KEY([DASId])
REFERENCES [dbo].[DAS] ([DASId])
GO

ALTER TABLE [dbo].[Channels] CHECK CONSTRAINT [FK_Channels_DASId]
GO

ALTER TABLE [dbo].[Channels]  WITH NOCHECK ADD  CONSTRAINT [FK_Channels_GroupId] FOREIGN KEY([GroupId])
REFERENCES [dbo].[Groups] ([Id])
GO

ALTER TABLE [dbo].[Channels] CHECK CONSTRAINT [FK_Channels_GroupId]
GO

ALTER TABLE [dbo].[Channels]  WITH NOCHECK ADD  CONSTRAINT [FK_Channels_SensorId] FOREIGN KEY([SensorId])
REFERENCES [dbo].[Sensors] ([id])
GO

ALTER TABLE [dbo].[Channels] CHECK CONSTRAINT [FK_Channels_SensorId]
GO


