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


GO
CREATE TABLE [dbo].[T_HAZIFELADATOK] (
    [ID]                  INT           IDENTITY (1, 1) NOT NULL,
    [C_FELADASDATUMA]     DATETIME      NOT NULL,
    [C_HATARIDO]          DATETIME      NOT NULL,
    [C_FELADATSZOVEGE]    NVARCHAR (20) NOT NULL,
    [C_ORASZAM]           INT           NULL,
    [C_ISTANARROGZITETTE] CHAR (1)      NOT NULL,
    [C_TANTARGYID]        INT           NOT NULL,
    [C_FELHASZNALOID]     INT           NOT NULL,
    [C_OSZTALYCSOPORTID]  INT           NOT NULL,
    [C_TANITASIORAID]     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_4028112] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_4028120_4028118]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028120_4028118]
    ON [dbo].[T_HAZIFELADATOK]([C_TANTARGYID] ASC);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_4028123_4028121]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028123_4028121]
    ON [dbo].[T_HAZIFELADATOK]([C_FELHASZNALOID] ASC);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_4028126_4028124]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028126_4028124]
    ON [dbo].[T_HAZIFELADATOK]([C_OSZTALYCSOPORTID] ASC);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_4028129_4028127]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028129_4028127]
    ON [dbo].[T_HAZIFELADATOK]([C_TANITASIORAID] ASC);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_402811202_402811200]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402811202_402811200]
    ON [dbo].[T_HAZIFELADATOK]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_HAZIFELADATOK].[I_T_402811205_402811203]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402811205_402811203]
    ON [dbo].[T_HAZIFELADATOK]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028120_4028118] FOREIGN KEY ([C_TANTARGYID]) REFERENCES [dbo].[T_TANTARGY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028123_4028121] FOREIGN KEY ([C_FELHASZNALOID]) REFERENCES [dbo].[T_FELHASZNALO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028126_4028124] FOREIGN KEY ([C_OSZTALYCSOPORTID]) REFERENCES [dbo].[T_OSZTALYCSOPORT] ([ID]);


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


GO
ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028129_4028127] FOREIGN KEY ([C_TANITASIORAID]) REFERENCES [dbo].[T_TANITASIORA] ([ID]);


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


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


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


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

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

GO
ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_4028120_4028118];

ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_4028123_4028121];

ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_4028126_4028124];

ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_4028129_4028127];

ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_402811202_402811200];

ALTER TABLE [dbo].[T_HAZIFELADATOK] WITH CHECK CHECK CONSTRAINT [FK_402811205_402811203];


GO
PRINT N'Update complete.';


GO
