﻿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_ERETTSEGIKERDES]...';


GO
CREATE TABLE [dbo].[T_ERETTSEGIKERDES] (
    [ID]                    INT             IDENTITY (1, 1) NOT NULL,
    [C_CIM]                 NVARCHAR (1000) NULL,
    [C_ERETTSEGISZINTID]    INT             NULL,
    [C_ERETTSEGITANTARGYID] INT             NULL,
    [C_HELYESVALASZ]        NVARCHAR (1000) NULL,
    [C_KATEGORIA]           NVARCHAR (10)   NOT NULL,
    [C_KEP]                 NVARCHAR (MAX)  NULL,
    [C_KERDES]              NVARCHAR (1000) NOT NULL,
    [C_SZOVEG]              NVARCHAR (2000) NULL,
    [C_TEMA]                NVARCHAR (1000) NOT NULL,
    [C_VALASZB]             NVARCHAR (1000) NULL,
    [C_VALASZC]             NVARCHAR (1000) NULL,
    [C_VALASZD]             NVARCHAR (1000) NULL,
    [C_VALASZE]             NVARCHAR (1000) NULL,
    [C_VALASZF]             NVARCHAR (1000) NULL,
    [C_VALASZSZOVEGES]      NVARCHAR (1000) 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_4028218] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIKERDES].[I_T_4028218_4028220]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028218_4028220]
    ON [dbo].[T_ERETTSEGIKERDES]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ERETTSEGISZINTID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIKERDES].[I_T_4028218_4028221]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028218_4028221]
    ON [dbo].[T_ERETTSEGIKERDES]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ERETTSEGITANTARGYID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIKERDES].[I_T_402821802_402821800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402821802_402821800]
    ON [dbo].[T_ERETTSEGIKERDES]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIKERDES].[I_T_402821805_402821803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402821805_402821803]
    ON [dbo].[T_ERETTSEGIKERDES]([C_TANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_ERETTSEGIVALASZ] (
    [ID]                  INT             IDENTITY (1, 1) NOT NULL,
    [C_DATUM]             DATETIME        NOT NULL,
    [C_HELYES]            CHAR (1)        NOT NULL,
    [C_VALASZ]            NVARCHAR (1000) NOT NULL,
    [C_TANULOID]          INT             NOT NULL,
    [C_ERETTSEGIKERDESID] 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_4028234] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIVALASZ].[I_T_4028240_4028238]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028240_4028238]
    ON [dbo].[T_ERETTSEGIVALASZ]([C_TANULOID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIVALASZ].[I_T_4028243_4028241]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028243_4028241]
    ON [dbo].[T_ERETTSEGIVALASZ]([C_ERETTSEGIKERDESID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIVALASZ].[I_T_402823402_402823400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402823402_402823400]
    ON [dbo].[T_ERETTSEGIVALASZ]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_ERETTSEGIVALASZ].[I_T_402823405_402823403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402823405_402823403]
    ON [dbo].[T_ERETTSEGIVALASZ]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH NOCHECK
    ADD CONSTRAINT [FK_4028218_4028220] FOREIGN KEY ([C_ERETTSEGISZINTID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ERETTSEGISZINT] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH NOCHECK
    ADD CONSTRAINT [FK_4028218_4028221] FOREIGN KEY ([C_ERETTSEGITANTARGYID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ERETTSEGITANTARGY] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH NOCHECK
    ADD CONSTRAINT [FK_4028240_4028238] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH NOCHECK
    ADD CONSTRAINT [FK_4028243_4028241] FOREIGN KEY ([C_ERETTSEGIKERDESID]) REFERENCES [dbo].[T_ERETTSEGIKERDES] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH CHECK CHECK CONSTRAINT [FK_402821802_402821800];

ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH CHECK CHECK CONSTRAINT [FK_402821805_402821803];

ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH CHECK CHECK CONSTRAINT [FK_4028218_4028220];

ALTER TABLE [dbo].[T_ERETTSEGIKERDES] WITH CHECK CHECK CONSTRAINT [FK_4028218_4028221];

ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH CHECK CHECK CONSTRAINT [FK_4028240_4028238];

ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH CHECK CHECK CONSTRAINT [FK_4028243_4028241];

ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH CHECK CHECK CONSTRAINT [FK_402823402_402823400];

ALTER TABLE [dbo].[T_ERETTSEGIVALASZ] WITH CHECK CHECK CONSTRAINT [FK_402823405_402823403];


GO
PRINT N'Update complete.';


GO
