USE [Elyse_DB]
GO
/****** Object:  Table [people].[function_lists]    Script Date: Sat 05-09-2026 7:01:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [people].[function_lists](
	[function_list_id] [bigint] NOT NULL,
	[function_id] [bigint] NOT NULL,
	[list_position] [int] NULL,
	[created] [datetime2](7) NOT NULL,
	[created_by] [nvarchar](255) NOT NULL,
	[valid_from] [datetime2](7) NULL,
	[valid_until] [datetime2](7) NULL,
	[app_reference] [nvarchar](1000) NULL,
	[notes] [nvarchar](1000) NULL,
 CONSTRAINT [PK_function_lists] PRIMARY KEY CLUSTERED 
(
	[function_list_id] ASC,
	[function_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]
GO
ALTER TABLE [people].[function_lists] ADD  CONSTRAINT [DF_function_lists_created]  DEFAULT (sysdatetime()) FOR [created]
GO
ALTER TABLE [people].[function_lists] ADD  CONSTRAINT [DF_function_lists_created_by]  DEFAULT (original_login()) FOR [created_by]
GO
ALTER TABLE [people].[function_lists]  WITH CHECK ADD  CONSTRAINT [FK_function_belongs_to_function_list] FOREIGN KEY([function_id])
REFERENCES [people].[duty_functions] ([function_id])
GO
ALTER TABLE [people].[function_lists] CHECK CONSTRAINT [FK_function_belongs_to_function_list]
GO
ALTER TABLE [people].[function_lists]  WITH CHECK ADD  CONSTRAINT [FK_function_list_has_function_list_name] FOREIGN KEY([function_list_id])
REFERENCES [people].[function_list_names] ([function_list_id])
GO
ALTER TABLE [people].[function_lists] CHECK CONSTRAINT [FK_function_list_has_function_list_name]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Position is an integer which allows a list of options in a table to be set in any order.  The value is unconstrained and must be set at the application layer.' , @level0type=N'SCHEMA',@level0name=N'people', @level1type=N'TABLE',@level1name=N'function_lists', @level2type=N'COLUMN',@level2name=N'list_position'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Creates lists of duty functions.  

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