/****** Object:  Table [dbo].[EST_PROD_TBL_DESC_CREDIARIO]    Script Date: 08/13/2013 16:54:00 ******/
IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_TBL_DESC_CREDIARIO]') AND type in (N'U'))
begin
	CREATE TABLE [dbo].[EST_PROD_TBL_DESC_CREDIARIO](
		[CD_EMP] [int] NOT NULL,
		[CD_TBL_DESC] [int] NOT NULL,
		[CD_MDL_VD] [int] NOT NULL,
		CONSTRAINT [PK_EST_PROD_TBL_DESC_CREDIARIO] PRIMARY KEY ([CD_EMP] ASC,	[CD_TBL_DESC] ASC,	[CD_MDL_VD] ASC)
	) 

	ALTER TABLE [dbo].[EST_PROD_TBL_DESC_CREDIARIO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TBL_DESC_CREDIARIO_EST_PROD_TBL_DESC] FOREIGN KEY([CD_EMP], [CD_TBL_DESC])
	REFERENCES [dbo].[EST_PROD_TBL_DESC] ([CD_EMP], [CD_TBL_DESC])


	ALTER TABLE [dbo].[EST_PROD_TBL_DESC_CREDIARIO] CHECK CONSTRAINT [FK_EST_PROD_TBL_DESC_CREDIARIO_EST_PROD_TBL_DESC]


	ALTER TABLE [dbo].[EST_PROD_TBL_DESC_CREDIARIO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TBL_DESC_CREDIARIO_RC_MDL_VENDA] FOREIGN KEY([CD_EMP], [CD_MDL_VD])
	REFERENCES [dbo].[RC_MDL_VENDA] ([CD_EMP], [CD_MDL_VD])


	ALTER TABLE [dbo].[EST_PROD_TBL_DESC_CREDIARIO] CHECK CONSTRAINT [FK_EST_PROD_TBL_DESC_CREDIARIO_RC_MDL_VENDA]
end

