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


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


GO
PRINT N'Creating [dbo].[T_SZAKTIPUS].[I_T_402830802_402830800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402830802_402830800]
    ON [dbo].[T_SZAKTIPUS]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_SZAKTIPUS].[I_T_402830805_402830803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402830805_402830803]
    ON [dbo].[T_SZAKTIPUS]([C_ALTANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_SZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028309];

ALTER TABLE [dbo].[T_SZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402830802_402830800];

ALTER TABLE [dbo].[T_SZAKTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402830805_402830803];


GO
PRINT N'Update complete.';


GO
