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


GO
CREATE TABLE [dbo].[T_VEGZETTSEGTIPUS] (
    [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_4028108] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_VEGZETTSEGTIPUS].[I_T_402810802_402810800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402810802_402810800]
    ON [dbo].[T_VEGZETTSEGTIPUS]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_VEGZETTSEGTIPUS].[I_T_402810805_402810803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402810805_402810803]
    ON [dbo].[T_VEGZETTSEGTIPUS]([C_ALTANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_VEGZETTSEGTIPUS] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028109];

ALTER TABLE [dbo].[T_VEGZETTSEGTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402810802_402810800];

ALTER TABLE [dbo].[T_VEGZETTSEGTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402810805_402810803];


GO
PRINT N'Update complete.';


GO
