﻿CREATE TABLE [dbo].[fuchs_planner_groups] (
    [group_id]       INT           NOT NULL,
    [code]           AS            ([dbo].[ott_b26]([group_id])),
    [planner_id]     TINYINT       NOT NULL,
    [sequence_order] TINYINT       CONSTRAINT [DF_fuchs_planner_groups_order] DEFAULT ((0)) NOT NULL,
    [parent_codes]   VARCHAR (50)  NULL,
    [condition]      VARCHAR (50)  NULL,
    [shortname]      VARCHAR (15)  NULL,
    [name]           VARCHAR (100) NULL,
    [description]    VARCHAR (MAX) NULL,
    [selection_type] VARCHAR (10)  NULL,
    [final]          BIT           CONSTRAINT [DF_fuchs_planner_groups_final] DEFAULT ((0)) NOT NULL,
    [hide]           BIT           CONSTRAINT [DF_fuchs_planner_groups_hide] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_fuchs_planner_groups] PRIMARY KEY CLUSTERED ([group_id] ASC),
    CONSTRAINT [FK_fuchs_planner_groups_fuchs_planner] FOREIGN KEY ([planner_id]) REFERENCES [dbo].[fuchs_planner] ([planner_id]),
    CONSTRAINT [FK_fuchs_planner_groups_fuchs_planner_groups] FOREIGN KEY ([group_id]) REFERENCES [dbo].[fuchs_planner_groups] ([group_id])
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_fuchs_planner_groups]
    ON [dbo].[fuchs_planner_groups]([planner_id] ASC, [sequence_order] ASC);

