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


GO
CREATE TABLE [dbo].[T_ELEARNINGELERHETOSEG] (
    [ID]                  INT           IDENTITY (1, 1) NOT NULL,
    [C_ELEARNINGAZONOSITO]         NVARCHAR (36) NOT NULL,
    [C_KEZDODATUM]        DATETIME      NULL,
    [C_SZEREPKORTIPUSID]  INT           NOT NULL,
    [C_VEGDATUM]          DATETIME      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_4028603] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_ELEARNINGELERHETOSEG].[I_T_4028603_4028606]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028603_4028606]
    ON [dbo].[T_ELEARNINGELERHETOSEG]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_SZEREPKORTIPUSID] ASC);


GO
PRINT N'Creating [dbo].[T_ELEARNINGELERHETOSEG].[I_T_402860302_402860300]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402860302_402860300]
    ON [dbo].[T_ELEARNINGELERHETOSEG]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_ELEARNINGELERHETOSEG].[I_T_402860305_402860303]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402860305_402860303]
    ON [dbo].[T_ELEARNINGELERHETOSEG]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_ELEARNINGELERHETOSEG] WITH NOCHECK
    ADD CONSTRAINT [FK_4028603_4028606] FOREIGN KEY ([C_SZEREPKORTIPUSID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_SZEREPKORTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
CREATE VIEW [dbo].T_ELEARNINGELERHETOSEG_OSSZES
        AS
        SELECT *
        FROM dbo.T_ELEARNINGELERHETOSEG
GO
PRINT N'Checking existing data against newly created constraints';


GO
ALTER TABLE [dbo].[T_ELEARNINGELERHETOSEG] WITH CHECK CHECK CONSTRAINT [FK_402860302_402860300];

ALTER TABLE [dbo].[T_ELEARNINGELERHETOSEG] WITH CHECK CHECK CONSTRAINT [FK_402860305_402860303];

ALTER TABLE [dbo].[T_ELEARNINGELERHETOSEG] WITH CHECK CHECK CONSTRAINT [FK_4028603_4028606];


GO
PRINT N'Update complete.';


GO

--------------------

EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO


ALTER QUEUE auditLog.[AuditQueue]
WITH ACTIVATION
( 
    STATUS = ON,
    PROCEDURE_NAME = auditLog.usp_AuditProcessing,
    MAX_QUEUE_READERS = 10,
    EXECUTE AS 'Kreta_tech_user'
);

GO