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


GO
CREATE TABLE [dbo].[T_FELJEGYZESTIPUS] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          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,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_T_4028110] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_FELJEGYZESTIPUS].[I_T_402811002_402811000]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402811002_402811000]
    ON [dbo].[T_FELJEGYZESTIPUS]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_FELJEGYZESTIPUS].[I_T_402811005_402811003]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402811005_402811003]
    ON [dbo].[T_FELJEGYZESTIPUS]([C_ALTANEVID] ASC);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_T_21038_4028111] FOREIGN KEY ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_DICTIONARYITEMBASE] ([ID], [C_INTEZMENYID], [C_TANEVID]);


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


GO
ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_402811002_402811000] FOREIGN KEY ([C_ALINTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_402811005_402811003] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028111];

ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402811002_402811000];

ALTER TABLE [dbo].[T_FELJEGYZESTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402811005_402811003];


GO
PRINT N'Update complete.';


GO
