﻿GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;


GO
PRINT N'Creating [dbo].[T_KIRKONTENER]...';


GO
CREATE TABLE [dbo].[T_KIRKONTENER] (
    [ID]                  INT           IDENTITY (1, 1) NOT NULL,
    [C_CELSZOLGALTATAS]   NVARCHAR (20) NOT NULL,
    [C_IARAZONOSITO]      NVARCHAR (30) NOT NULL,
    [C_KONTENERID]        INT           NOT NULL,
    [C_OMKOD]             NVARCHAR (20) NOT NULL,
    [C_VALASZKOD]         NVARCHAR (20) NOT NULL,
    [C_INTEZMENYID]       INT           NOT NULL,
    [C_TANEVID]           INT           NOT NULL,
    [TOROLT]              CHAR (1)      NOT NULL,
    [SERIAL]              INT           NOT NULL,
    [LASTCHANGED]         DATETIME      NOT NULL,
    [CREATED]             DATETIME      NOT NULL,
    [MODIFIER]            INT           NULL,
    [CREATOR]             INT           NULL,
    [ELOZOTANEVIREKORDID] INT           NULL,
    [NNID]                INT           NULL,
    CONSTRAINT [PK_T_4028321] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_KIRKONTENER].[I_T_402832102_402832100]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402832102_402832100]
    ON [dbo].[T_KIRKONTENER]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENER].[I_T_402832105_402832103]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402832105_402832103]
    ON [dbo].[T_KIRKONTENER]([C_TANEVID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERELEM]...';


GO
CREATE TABLE [dbo].[T_KIRKONTENERELEM] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_KONTENERELEMID]    INT      NULL,
    [C_KIRKONTENERID]     INT      NOT NULL,
    [C_INTEZMENYID]       INT      NOT NULL,
    [C_TANEVID]           INT      NOT NULL,
    [TOROLT]              CHAR (1) NOT NULL,
    [SERIAL]              INT      NOT NULL,
    [LASTCHANGED]         DATETIME NOT NULL,
    [CREATED]             DATETIME NOT NULL,
    [MODIFIER]            INT      NULL,
    [CREATOR]             INT      NULL,
    [ELOZOTANEVIREKORDID] INT      NULL,
    [NNID]                INT      NULL,
    CONSTRAINT [PK_T_4028314] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERELEM].[I_T_4028331_4028329]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028331_4028329]
    ON [dbo].[T_KIRKONTENERELEM]([C_KIRKONTENERID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERELEM].[I_T_402831402_402831400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402831402_402831400]
    ON [dbo].[T_KIRKONTENERELEM]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERELEM].[I_T_402831405_402831403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402831405_402831403]
    ON [dbo].[T_KIRKONTENERELEM]([C_TANEVID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERSTATUSZ]...';


GO
CREATE TABLE [dbo].[T_KIRKONTENERSTATUSZ] (
    [ID]                  INT           IDENTITY (1, 1) NOT NULL,
    [C_KONTENERSTATUSZ]   NVARCHAR (20) NULL,
    [C_MESSAGECODE]       NVARCHAR (20) NULL,
    [C_MESSAGESOURCE]     NVARCHAR (20) NULL,
    [C_MESSAGETEXT]       NVARCHAR (20) NULL,
    [C_KIRKONTENERELEMID] INT           NULL,
    [C_KIRKONTENERID]     INT           NULL,
    [C_INTEZMENYID]       INT           NOT NULL,
    [C_TANEVID]           INT           NOT NULL,
    [TOROLT]              CHAR (1)      NOT NULL,
    [SERIAL]              INT           NOT NULL,
    [LASTCHANGED]         DATETIME      NOT NULL,
    [CREATED]             DATETIME      NOT NULL,
    [MODIFIER]            INT           NULL,
    [CREATOR]             INT           NULL,
    [ELOZOTANEVIREKORDID] INT           NULL,
    [NNID]                INT           NULL,
    CONSTRAINT [PK_T_4028316] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERSTATUSZ].[I_T_4028327_4028326]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028327_4028326]
    ON [dbo].[T_KIRKONTENERSTATUSZ]([C_KIRKONTENERELEMID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERSTATUSZ].[I_T_4028333_4028332]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028333_4028332]
    ON [dbo].[T_KIRKONTENERSTATUSZ]([C_KIRKONTENERID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERSTATUSZ].[I_T_402831602_402831600]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402831602_402831600]
    ON [dbo].[T_KIRKONTENERSTATUSZ]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_KIRKONTENERSTATUSZ].[I_T_402831605_402831603]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402831605_402831603]
    ON [dbo].[T_KIRKONTENERSTATUSZ]([C_TANEVID] ASC);


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENER]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER]
    ADD DEFAULT ((0)) FOR [SERIAL];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENER]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER]
    ADD DEFAULT (getdate()) FOR [CREATED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENER]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENER]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERELEM]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM]
    ADD DEFAULT (getdate()) FOR [CREATED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERELEM]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM]
    ADD DEFAULT ((0)) FOR [SERIAL];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERELEM]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERELEM]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERSTATUSZ]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ]
    ADD DEFAULT ((0)) FOR [SERIAL];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERSTATUSZ]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ]
    ADD DEFAULT (getdate()) FOR [CREATED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERSTATUSZ]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_KIRKONTENERSTATUSZ]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating [dbo].[FK_402832102_402832100]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER] WITH NOCHECK
    ADD CONSTRAINT [FK_402832102_402832100] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402832105_402832103]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENER] WITH NOCHECK
    ADD CONSTRAINT [FK_402832105_402832103] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4028331_4028329]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH NOCHECK
    ADD CONSTRAINT [FK_4028331_4028329] FOREIGN KEY ([C_KIRKONTENERID]) REFERENCES [dbo].[T_KIRKONTENER] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402831402_402831400]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH NOCHECK
    ADD CONSTRAINT [FK_402831402_402831400] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402831405_402831403]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH NOCHECK
    ADD CONSTRAINT [FK_402831405_402831403] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4028327_4028326]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH NOCHECK
    ADD CONSTRAINT [FK_4028327_4028326] FOREIGN KEY ([C_KIRKONTENERELEMID]) REFERENCES [dbo].[T_KIRKONTENERELEM] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4028333_4028332]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH NOCHECK
    ADD CONSTRAINT [FK_4028333_4028332] FOREIGN KEY ([C_KIRKONTENERID]) REFERENCES [dbo].[T_KIRKONTENER] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402831602_402831600]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH NOCHECK
    ADD CONSTRAINT [FK_402831602_402831600] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402831605_402831603]...';


GO
ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH NOCHECK
    ADD CONSTRAINT [FK_402831605_402831603] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


GO
PRINT N'Checking existing data against newly created constraints';


GO
ALTER TABLE [dbo].[T_KIRKONTENER] WITH CHECK CHECK CONSTRAINT [FK_402832102_402832100];

ALTER TABLE [dbo].[T_KIRKONTENER] WITH CHECK CHECK CONSTRAINT [FK_402832105_402832103];

ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH CHECK CHECK CONSTRAINT [FK_4028331_4028329];

ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH CHECK CHECK CONSTRAINT [FK_402831402_402831400];

ALTER TABLE [dbo].[T_KIRKONTENERELEM] WITH CHECK CHECK CONSTRAINT [FK_402831405_402831403];

ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_4028327_4028326];

ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_4028333_4028332];

ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_402831602_402831600];

ALTER TABLE [dbo].[T_KIRKONTENERSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_402831605_402831603];


GO
PRINT N'Update complete.';


GO
