USE [Elyse_DB]
GO
/****** Object:  Table [xref].[doc_group_names]    Script Date: Sat 05-09-2026 7:01:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [xref].[doc_group_names](
	[doc_group_id] [bigint] IDENTITY(1,1) NOT NULL,
	[mnem] [nvarchar](10) NULL,
	[attr_name] [nvarchar](50) NOT NULL,
	[descr] [nvarchar](max) NULL,
	[created] [datetime2](7) NOT NULL,
	[created_by] [nvarchar](255) NOT NULL,
 CONSTRAINT [PK_doc_group_name] PRIMARY KEY CLUSTERED 
(
	[doc_group_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object:  Index [UN_group_name]    Script Date: Sat 05-09-2026 7:01:55 AM ******/
CREATE NONCLUSTERED INDEX [UN_group_name] ON [xref].[doc_group_names]
(
	[attr_name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
GO
ALTER TABLE [xref].[doc_group_names] ADD  CONSTRAINT [DF_doc_group_names_created]  DEFAULT (sysdatetime()) FOR [created]
GO
ALTER TABLE [xref].[doc_group_names] ADD  CONSTRAINT [DF_doc_group_names_created_by]  DEFAULT (original_login()) FOR [created_by]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is a short mnemonic for the attribute.  Mnemonics are useful for saving space when displaying tables. ' , @level0type=N'SCHEMA',@level0name=N'xref', @level1type=N'TABLE',@level1name=N'doc_group_names', @level2type=N'COLUMN',@level2name=N'mnem'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is the name of the attribute, which is that which the application will most likely present to the user.  ' , @level0type=N'SCHEMA',@level0name=N'xref', @level1type=N'TABLE',@level1name=N'doc_group_names', @level2type=N'COLUMN',@level2name=N'attr_name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Description.  Allows the user to enter a long narrative if necessary. ' , @level0type=N'SCHEMA',@level0name=N'xref', @level1type=N'TABLE',@level1name=N'doc_group_names', @level2type=N'COLUMN',@level2name=N'descr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Document group name must be unique' , @level0type=N'SCHEMA',@level0name=N'xref', @level1type=N'TABLE',@level1name=N'doc_group_names', @level2type=N'INDEX',@level2name=N'UN_group_name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is the name of a group of documents.

Note that The column attr_name is set to NOT NULL and UNIQUE.  In some circumstances however this table may be superfluous if there is a desire to create a 1:1 relationship and not impose on the user to create a group.  In that case then the application layer can automatcially enter a small guid for the name and hide this table data from the user, effectively bypassing the grouping.

COPYRIGHT NOTICE
This database schema and stored procedures are protected by copyright.
Copyright.  Silkwood Software Pty. Ltd. 2023
' , @level0type=N'SCHEMA',@level0name=N'xref', @level1type=N'TABLE',@level1name=N'doc_group_names'
GO
