USE [DD_ECM]
GO
/****** Object:  Table [dbo].[TBEDI_XML_TEMPLATE_ITEMS]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[ORDER_KEY] [int] NOT NULL,
	[XML_NAME] [nvarchar](50) NOT NULL,
	[XML_TABLE_ID] [int] NOT NULL,
	[XML_TYPE_ID] [int] NOT NULL,
	[IS_READ_ONLY] [bit] NOT NULL,
	[IS_VISIBLE] [bit] NOT NULL,
	[IS_REQUIRED] [bit] NOT NULL,
	[IS_VIRTUAL] [bit] NOT NULL,
	[FUNCTION_ID] [int] NULL,
	[FUNCTION_PARAMETERS] [nvarchar](max) NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK__TBEDI_XM__15B69B8E6125D501] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBEDI_XML_MAPPING_CONFIG]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_MAPPING_CONFIG](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[ORDER_KEY] [int] NOT NULL,
	[SOURCE_ENTITY_ID] [int] NOT NULL,
	[SOURCE_REGEX] [nvarchar](100) NOT NULL,
	[DESTINATION_ENTITY_ID] [int] NOT NULL,
	[DESTINATION_VALUE] [nvarchar](100) NOT NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [nchar](10) NULL,
 CONSTRAINT [PK_TBEDI_XML_MAPPING_CONFIG] PRIMARY KEY CLUSTERED 
(
	[GUID] 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
/****** Object:  Table [dbo].[TBEDI_XML_MAPPING_ENTITY]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_MAPPING_ENTITY](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](100) NULL,
	[ITEM_ID] [int] NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBEDI_XML_MAPPING_ENTITY] PRIMARY KEY CLUSTERED 
(
	[GUID] 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
/****** Object:  View [dbo].[VWEDI_XML_MAPPING]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE VIEW [dbo].[VWEDI_XML_MAPPING]
AS
SELECT        
TBEDI_XML_MAPPING_CONFIG.ORDER_KEY, 

TSOURCE.NAME AS SOURCE_NAME, 
TSOURCE_ITEMS.XML_NAME SOURCE_ITEM,
TBEDI_XML_MAPPING_CONFIG.SOURCE_REGEX,

TDESTINATION.NAME AS DESTINATION_NAME, 
TDESTINATION_ITEMS.XML_NAME AS DESTINATION_ITEM, 
TBEDI_XML_MAPPING_CONFIG.DESTINATION_VALUE

FROM            
	dbo.TBEDI_XML_MAPPING_CONFIG 
	INNER JOIN TBEDI_XML_MAPPING_ENTITY AS TSOURCE ON TBEDI_XML_MAPPING_CONFIG.SOURCE_ENTITY_ID = TSOURCE.GUID
    INNER JOIN TBEDI_XML_MAPPING_ENTITY AS TDESTINATION ON TBEDI_XML_MAPPING_CONFIG.DESTINATION_ENTITY_ID = TDESTINATION.GUID
	LEFT OUTER JOIN TBEDI_XML_TEMPLATE_ITEMS AS TSOURCE_ITEMS ON TSOURCE.ITEM_ID = TSOURCE_ITEMS.GUID
	LEFT OUTER JOIN TBEDI_XML_TEMPLATE_ITEMS AS TDESTINATION_ITEMS ON TDESTINATION.ITEM_ID = TDESTINATION_ITEMS.GUID
GO
/****** Object:  Table [dbo].[TBEDI_XML_TABLES]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_TABLES](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](max) NOT NULL,
	[TEMPLATE_ID] [int] NOT NULL,
	[IS_HEAD] [bit] NOT NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK__TBEDI_XM__15B69B8E6F74D014] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBEDI_XML_TYPES]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_TYPES](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](20) NOT NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK__TBEDI_XM__15B69B8E5B32E7AF] PRIMARY KEY CLUSTERED 
(
	[GUID] 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
/****** Object:  Table [dbo].[TBEDI_XML_TEMPLATES]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_TEMPLATES](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](20) NOT NULL,
	[DESCRIPTION] [nvarchar](max) NULL,
	[FILE_NAME] [nvarchar](100) NULL,
	[IS_IMPORT] [bit] NULL,
	[ACTIVE] [bit] NOT NULL,
	[PARAMETER_1] [nvarchar](500) NULL,
	[PARAMETER_2] [nvarchar](500) NULL,
	[FINAL_SQL] [nvarchar](500) NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK__TBEDI_XM__15B69B8E8C482F3B] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBEDI_XML_FUNCTIONS]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_FUNCTIONS](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](max) NOT NULL,
	[DESCRIPTION] [nvarchar](max) NOT NULL,
	[PARAMETERS] [nvarchar](max) NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK__TBEDI_XM__15B69B8E0E5FF7EC] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  View [dbo].[VWEDI_XML_ITEMS]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO





CREATE VIEW [dbo].[VWEDI_XML_ITEMS]
AS
	SELECT DISTINCT
		[TBTEMPLATES].[NAME] [TEMPLATE_NAME]
		,[TBTABLES].[NAME] AS [XML_TABLE]
		,[TBITEMS].[XML_NAME] AS [XML_ITEM]		
		,[TBTYPES].[NAME] AS [DATA_TYPE]
		,[TBTABLES].[IS_HEAD] AS [IS_HEAD]
		,[TBITEMS].[IS_READ_ONLY]
		,[TBITEMS].[IS_VISIBLE]
        ,[TBITEMS].[IS_REQUIRED]
		,[TBITEMS].[IS_VIRTUAL]
		,[TBITEMS].[ORDER_KEY]
		,[TBFUNCTIONS].[GUID] AS [FUNCTION_ID]
		,[TBFUNCTIONS].[NAME] AS [FUNCTION_NAME]
		,[TBITEMS].[FUNCTION_PARAMETERS]
	FROM
		[dbo].[TBEDI_XML_TEMPLATE_ITEMS] [TBITEMS]
		INNER JOIN [dbo].[TBEDI_XML_TABLES] [TBTABLES] ON [TBITEMS].[XML_TABLE_ID] = [TBTABLES].[GUID]
		INNER JOIN [dbo].[TBEDI_XML_TYPES] [TBTYPES] ON [TBITEMS].[XML_TYPE_ID] = [TBTYPES].[GUID]
		INNER JOIN [dbo].[TBEDI_XML_TEMPLATES] [TBTEMPLATES] ON [TBTABLES].[TEMPLATE_ID] = [TBTEMPLATES].[GUID]
		LEFT OUTER JOIN [dbo].[TBEDI_XML_FUNCTIONS] [TBFUNCTIONS] ON [TBITEMS].[FUNCTION_ID] = [TBFUNCTIONS].[GUID]
		
GO
/****** Object:  Table [dbo].[TBEDI_XML_CONFIG]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_CONFIG](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[KEY] [nvarchar](100) NOT NULL,
	[VALUE] [nvarchar](500) NOT NULL,
	[TEMPLATE_ID] [int] NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBEDI_XML_CONFIG] PRIMARY KEY CLUSTERED 
(
	[GUID] 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
/****** Object:  Table [dbo].[TBEDI_XML_MANDATORS]    Script Date: 24.01.2022 12:31:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBEDI_XML_MANDATORS](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](50) NULL,
	[ORDER_KEY] [int] NULL,
	[ACTIVE] [bit] NOT NULL,
	[COMMENT] [nvarchar](100) NULL,
	[ADDED_WHO] [nvarchar](50) NULL,
	[ADDED_WHEN] [datetime] NULL,
	[CHANGED_WHO] [nvarchar](50) NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBEDI_XML_MANDATORS] PRIMARY KEY CLUSTERED 
(
	[GUID] 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].[TBEDI_XML_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_CONFIG_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_CONFIG_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_CONFIG_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_FUNCTIONS] ADD  CONSTRAINT [DF_TBEDI_XML_FUNCTIONS_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_FUNCTIONS] ADD  CONSTRAINT [DF_TBEDI_XML_FUNCTIONS_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_FUNCTIONS] ADD  CONSTRAINT [DF_TBEDI_XML_FUNCTIONS_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_MANDATORS] ADD  CONSTRAINT [DF_TBEDI_XML_MANDATORS_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_VALUE_MAPPING_ORDER_KEY]  DEFAULT ((0)) FOR [ORDER_KEY]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_CONFIG_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_CONFIG_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_CONFIG] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_CONFIG_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_ENTITY] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_ENTITY_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_ENTITY] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_ENTITY_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_MAPPING_ENTITY] ADD  CONSTRAINT [DF_TBEDI_XML_MAPPING_ENTITY_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_TABLES] ADD  CONSTRAINT [DF_TBEDI_XML_NODES_IS_HEAD]  DEFAULT ((0)) FOR [IS_HEAD]
GO
ALTER TABLE [dbo].[TBEDI_XML_TABLES] ADD  CONSTRAINT [DF_TBEDI_XML_TABLES_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_TABLES] ADD  CONSTRAINT [DF_TBEDI_XML_TABLES_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_TABLES] ADD  CONSTRAINT [DF_TBEDI_XML_TABLES_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_ORDER_KEY]  DEFAULT ((0)) FOR [ORDER_KEY]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_IS_READ_ONLY]  DEFAULT ((0)) FOR [IS_READ_ONLY]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_IS_VISIBLE]  DEFAULT ((0)) FOR [IS_VISIBLE]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_IS_REQUIRED]  DEFAULT ((0)) FOR [IS_REQUIRED]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_IS_VIRTUAL]  DEFAULT ((0)) FOR [IS_VIRTUAL]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ADD  CONSTRAINT [DF_TBEDI_XML_ITEMS_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATES] ADD  CONSTRAINT [DF_TBEDI_XML_TEMPLATES_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATES] ADD  CONSTRAINT [DF_TBEDI_XML_TEMPLATES_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATES] ADD  CONSTRAINT [DF_TBEDI_XML_TEMPLATES_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_TYPES] ADD  CONSTRAINT [DF_TBEDI_XML_TYPES_ACTIVE]  DEFAULT ((1)) FOR [ACTIVE]
GO
ALTER TABLE [dbo].[TBEDI_XML_TYPES] ADD  CONSTRAINT [DF_TBEDI_XML_TYPES_ADDED_WHO]  DEFAULT (N'DEFAULT') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBEDI_XML_TYPES] ADD  CONSTRAINT [DF_TBEDI_XML_TYPES_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS]  WITH CHECK ADD  CONSTRAINT [FK_TBEDI_XML_NODES] FOREIGN KEY([XML_TABLE_ID])
REFERENCES [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ([GUID])
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] CHECK CONSTRAINT [FK_TBEDI_XML_NODES]
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS]  WITH CHECK ADD  CONSTRAINT [FK_TBEDI_XML_TYPES] FOREIGN KEY([XML_TYPE_ID])
REFERENCES [dbo].[TBEDI_XML_TEMPLATE_ITEMS] ([GUID])
GO
ALTER TABLE [dbo].[TBEDI_XML_TEMPLATE_ITEMS] CHECK CONSTRAINT [FK_TBEDI_XML_TYPES]
GO