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


GO
CREATE TABLE [dbo].[T_UZENET] (
    [ID]                  INT             IDENTITY (1, 1) NOT NULL,
    [C_ERTESITES]         CHAR (1)        NOT NULL,
    [C_FELADONEV]         NVARCHAR (300)  NULL,
    [C_TARGY]             NVARCHAR (300)  NOT NULL,
    [C_TARTALOM]          NVARCHAR (4000) NOT NULL,
    [C_EREDETIUZENETID]   INT             NULL,
    [C_FELADOID]          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_4028248] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_UZENET].[I_T_4028264_4028263]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028264_4028263]
    ON [dbo].[T_UZENET]([C_FELADOID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENET].[I_T_402824802_402824800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402824802_402824800]
    ON [dbo].[T_UZENET]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENET].[I_T_402824805_402824803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402824805_402824803]
    ON [dbo].[T_UZENET]([C_TANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_UZENETCIMZETT] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_ARCHIVALT]         CHAR (1) NOT NULL,
    [C_OLVASOTT]          CHAR (1) NOT NULL,
    [C_UZENETID]          INT      NOT NULL,
    [C_FELHASZNALOID]     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_4028257] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_UZENETCIMZETT].[I_T_4028262_4028260]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028262_4028260]
    ON [dbo].[T_UZENETCIMZETT]([C_UZENETID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETCIMZETT].[I_T_4028268_4028266]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028268_4028266]
    ON [dbo].[T_UZENETCIMZETT]([C_FELHASZNALOID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETCIMZETT].[I_T_402825702_402825700]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402825702_402825700]
    ON [dbo].[T_UZENETCIMZETT]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETCIMZETT].[I_T_402825705_402825703]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402825705_402825703]
    ON [dbo].[T_UZENETCIMZETT]([C_TANEVID] ASC);


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


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


GO
PRINT N'Creating [dbo].[T_UZENETJOGKORTIPUS].[I_T_402825602_402825600]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402825602_402825600]
    ON [dbo].[T_UZENETJOGKORTIPUS]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETJOGKORTIPUS].[I_T_402825605_402825603]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402825605_402825603]
    ON [dbo].[T_UZENETJOGKORTIPUS]([C_ALTANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_UZENETJOGOK] (
    [ID]                  INT      IDENTITY (1, 1) NOT NULL,
    [C_CIMZETTJOGKORID]   INT      NOT NULL,
    [C_CSAKKAPCSOLODO]    CHAR (1) NOT NULL,
    [C_FELADOJOGKORID]    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_4028244] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_UZENETJOGOK].[I_T_4028244_4028253]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028244_4028253]
    ON [dbo].[T_UZENETJOGOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_CIMZETTJOGKORID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETJOGOK].[I_T_4028244_4028255]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028244_4028255]
    ON [dbo].[T_UZENETJOGOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_FELADOJOGKORID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETJOGOK].[I_T_402824402_402824400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402824402_402824400]
    ON [dbo].[T_UZENETJOGOK]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_UZENETJOGOK].[I_T_402824405_402824403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402824405_402824403]
    ON [dbo].[T_UZENETJOGOK]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENET]
    ADD DEFAULT ('F') FOR [C_ERTESITES];


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENETCIMZETT]
    ADD DEFAULT ('F') FOR [C_OLVASOTT];


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


GO
ALTER TABLE [dbo].[T_UZENETCIMZETT]
    ADD DEFAULT ('F') FOR [C_ARCHIVALT];


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENETJOGOK]
    ADD DEFAULT ('F') FOR [C_CSAKKAPCSOLODO];


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENET] WITH NOCHECK
    ADD CONSTRAINT [FK_4028264_4028263] FOREIGN KEY ([C_FELADOID]) REFERENCES [dbo].[T_FELHASZNALO] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENETCIMZETT] WITH NOCHECK
    ADD CONSTRAINT [FK_4028262_4028260] FOREIGN KEY ([C_UZENETID]) REFERENCES [dbo].[T_UZENET] ([ID]);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_UZENETJOGOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028244_4028253] FOREIGN KEY ([C_CIMZETTJOGKORID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_UZENETJOGKORTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_UZENETJOGOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4028244_4028255] FOREIGN KEY ([C_FELADOJOGKORID], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_UZENETJOGKORTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_UZENET] WITH CHECK CHECK CONSTRAINT [FK_4028264_4028263];

ALTER TABLE [dbo].[T_UZENET] WITH CHECK CHECK CONSTRAINT [FK_402824802_402824800];

ALTER TABLE [dbo].[T_UZENET] WITH CHECK CHECK CONSTRAINT [FK_402824805_402824803];

ALTER TABLE [dbo].[T_UZENETCIMZETT] WITH CHECK CHECK CONSTRAINT [FK_4028262_4028260];

ALTER TABLE [dbo].[T_UZENETCIMZETT] WITH CHECK CHECK CONSTRAINT [FK_4028268_4028266];

ALTER TABLE [dbo].[T_UZENETCIMZETT] WITH CHECK CHECK CONSTRAINT [FK_402825702_402825700];

ALTER TABLE [dbo].[T_UZENETCIMZETT] WITH CHECK CHECK CONSTRAINT [FK_402825705_402825703];

ALTER TABLE [dbo].[T_UZENETJOGKORTIPUS] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028269];

ALTER TABLE [dbo].[T_UZENETJOGKORTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402825602_402825600];

ALTER TABLE [dbo].[T_UZENETJOGKORTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402825605_402825603];

ALTER TABLE [dbo].[T_UZENETJOGOK] WITH CHECK CHECK CONSTRAINT [FK_402824402_402824400];

ALTER TABLE [dbo].[T_UZENETJOGOK] WITH CHECK CHECK CONSTRAINT [FK_402824405_402824403];

ALTER TABLE [dbo].[T_UZENETJOGOK] WITH CHECK CHECK CONSTRAINT [FK_4028244_4028253];

ALTER TABLE [dbo].[T_UZENETJOGOK] WITH CHECK CHECK CONSTRAINT [FK_4028244_4028255];


GO
PRINT N'Update complete.';


GO
