Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
?CREATE TABLE seclyr.Users
(
--fields
UserID [int] IDENTITY(1,1) NOT NULL,
ADDomain [varchar] (20) NOT NULL,
FirstName [varchar](100) NULL,
LastName [varchar](100),
UserName [varchar](50),
EmailAddress [varchar](100),
PhoneNumber [varchar](50),
PhoneExtension [varchar](10),
SupervisorName [varchar](100) NULL,
SupervisorPhoneNumber [varchar](50) NULL,
SupervisorEmailAddress [varchar](100),
CreatedByUserName [varchar] (50) NULL,
UpdatedByUserName [varchar] (50) NULL,
DateCreated [datetime2](7),
DateUpdated [datetime2](7),
DateLastLogin [datetime2](7),
DateInactive [datetime2](7),
Inactive [bit] NOT NULL,
CompletedRequestForm [bit] NOT NULL,
--primary key
CONSTRAINT PK_Users PRIMARY KEY CLUSTERED
(
UserID ASC
)
)
ON DefinitionData
--when using clustered columnstore index, can't set data compression to PAGE
--WITH (DATA_COMPRESSION = PAGE) --less than 10,000 rows, don't need compression
GO
--foreign keys
--indexes
CREATE NONCLUSTERED INDEX IX_Users_NtDomain ON seclyr.Users
(
ADDomain ASC
) WITH (
PAD_INDEX = ON, --If want to use a Fill Factor, then PAD_INDEX must = ON
FILLFACTOR = 90, --100 = max fill; set to 90 if going to insert new values incrementally; 100 if doing bulk load
SORT_IN_TEMPDB = ON, -- sorts the index in the TempDB; default = OFF
IGNORE_DUP_KEY = OFF,
STATISTICS_NORECOMPUTE = OFF,
STATISTICS_INCREMENTAL = OFF,
DROP_EXISTING = OFF,
ONLINE = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON,
MAXDOP = 0, --degrees of parallelism, controls how many CPUs to use; 0 = default (all available), max = 64
DATA_COMPRESSION = NONE --don't need, less than 10,000 rows
)
ON DefinitionIndex
GO
CREATE NONCLUSTERED INDEX IX_Users_UserName ON seclyr.Users
(
UserName ASC
) WITH (
PAD_INDEX = ON, --If want to use a Fill Factor, then PAD_INDEX must = ON
FILLFACTOR = 90, --100 = max fill; set to 90 if going to insert new values incrementally; 100 if doing bulk load
SORT_IN_TEMPDB = ON, -- sorts the index in the TempDB; default = OFF
IGNORE_DUP_KEY = OFF,
STATISTICS_NORECOMPUTE = OFF,
STATISTICS_INCREMENTAL = OFF,
DROP_EXISTING = OFF,
ONLINE = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON,
MAXDOP = 0, --degrees of parallelism, controls how many CPUs to use; 0 = default (all available), max = 64
DATA_COMPRESSION = NONE --don't need, less than 10,000 rows
)
ON DefinitionIndex
GO
CREATE NONCLUSTERED INDEX IX_Users_EmailAddress ON seclyr.Users
(
EmailAddress ASC
) WITH (
PAD_INDEX = ON, --If want to use a Fill Factor, then PAD_INDEX must = ON
FILLFACTOR = 90, --100 = max fill; set to 90 if going to insert new values incrementally; 100 if doing bulk load
SORT_IN_TEMPDB = ON, -- sorts the index in the TempDB; default = OFF
IGNORE_DUP_KEY = OFF,
STATISTICS_NORECOMPUTE = OFF,
STATISTICS_INCREMENTAL = OFF,
DROP_EXISTING = OFF,
ONLINE = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON,
MAXDOP = 0, --degrees of parallelism, controls how many CPUs to use; 0 = default (all available), max = 64
DATA_COMPRESSION = NONE --don't need, less than 10,000 rows
)
ON DefinitionIndex
GO
--constraints
ALTER TABLE seclyr.Users
ADD CONSTRAINT DF_Users_Inactive
DEFAULT 0
FOR Inactive
GO
ALTER TABLE seclyr.Users
ADD CONSTRAINT DF_Users_CompletedRequestForm
DEFAULT 0
FOR CompletedRequestForm
GO
--Metadata descriptions for each field
EXECUTE sp_addextendedproperty
N'MS_Description', N'Primary Key, unique to EPRS',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'UserID'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Windows Active Directory domain where the user is logging in from',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'ADDomain'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'First name of the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'FirstName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Last name of the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'LastName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Login name for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'UserName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Email address for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'EmailAddress'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Phone number for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'PhoneNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Phone extension for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'PhoneExtension'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Supervisor name for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'SupervisorName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Supervisor phone number for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'SupervisorPhoneNumber'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Supervisor email address for the user',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'SupervisorEmailAddress'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'AD Account of Person who created the record, not foreign keys because could cause issues, being self-referential',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'CreatedByUserName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'AD Account of Person who last updated the record, not foreign keys because could cause issues, being self-referential',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'UpdatedByUserName'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Date record was created',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'DateCreated'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Date user entered record',
N'SCHEMA', N'seclyr', N'TABLE', N'Users', N'COLUMN', N'DateUpdated'
GO
EXECUTE sp_addextendedproperty N'MS_Description', N'Date user last logged in',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'DateLastLogin'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Date record was inactivated',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'DateInactive'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Identifies if the record is inactive',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'Inactive'
GO
EXECUTE sp_addextendedproperty
N'MS_Description', N'Identifies if the user has completed a request form',
N'SCHEMA', N'seclyr',
N'TABLE', N'Users',
N'COLUMN', N'CompletedRequestForm'
GO