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


GO
CREATE TABLE [dbo].[T_HITTANADATSZOLGALTATAS] (
    [ID]                  INT             IDENTITY (1, 1) NOT NULL,
    [C_EDDIGIORASZAM]     NUMERIC (10, 2) NULL,
    [C_HITTANTIPUSID]     INT             NULL,
    [C_OSZTALYCSOPORTID]  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_4028135] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_HITTANADATSZOLGALTATAS].[I_T_4028135_4028137]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028135_4028137]
    ON [dbo].[T_HITTANADATSZOLGALTATAS]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_HITTANTIPUSID] ASC);


GO
PRINT N'Creating [dbo].[T_HITTANADATSZOLGALTATAS].[I_T_4028139_4028138]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028139_4028138]
    ON [dbo].[T_HITTANADATSZOLGALTATAS]([C_OSZTALYCSOPORTID] ASC);


GO
PRINT N'Creating [dbo].[T_HITTANADATSZOLGALTATAS].[I_T_402813502_402813500]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402813502_402813500]
    ON [dbo].[T_HITTANADATSZOLGALTATAS]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_HITTANADATSZOLGALTATAS].[I_T_402813505_402813503]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402813505_402813503]
    ON [dbo].[T_HITTANADATSZOLGALTATAS]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_HITTANADATSZOLGALTATAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4028135_4028137] FOREIGN KEY ([C_HITTANTIPUSID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_HITTANTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_HITTANADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_4028135_4028137];

ALTER TABLE [dbo].[T_HITTANADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_4028139_4028138];

ALTER TABLE [dbo].[T_HITTANADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_402813502_402813500];

ALTER TABLE [dbo].[T_HITTANADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_402813505_402813503];


GO
PRINT N'Update complete.';


GO
