CREATE TABLE [Borger].[DimBorger](
  [DimBorgerID] [bigint] NOT NULL,
  [Personnummer] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Fornavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Efternavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Fødselsdato] [datetime2](3) NULL,
  [Køn] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Civilstand] [varchar](40) COLLATE Norwegian_100_CI_AS NULL,
  [PersonnummerÆgtefælle] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Kommunalttilhørsforhold] [varchar](40) COLLATE Norwegian_100_CI_AS NULL,
  [Statsborgerland] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Fødested] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Herkomst] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [ErBeskyttet] [int] NULL,
  [ErUmyndig] [int] NULL,
  [PersonnummerFar] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [PersonnummerMor] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Forældremyndighed] [varchar](30) COLLATE Norwegian_100_CI_AS NULL,
  [Kirkeoplysning] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [GældendeFra] [datetime2](3) NULL,
  [GældendeTil] [datetime2](3) NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] [bigint] identity(1,1) NOT NULL,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL,
  CONSTRAINT PK_DimBorger PRIMARY KEY CLUSTERED (DimBorgerID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_Borger_DimBorger]
On [Borger].[DimBorger] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerdimensionen, dvs. en liste over alle personer i EDW.Person.', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Surrogatnøgle', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'DimBorgerID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens CPR nr.', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Personnummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Farnavn', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Fornavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Mellemnavn + Efternavn', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Efternavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fødselsdato', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Fødselsdato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens køn', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Køn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens Civilstand', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Civilstand';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens Ægtefælles CPR nr.', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'PersonnummerÆgtefælle';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver personens kommunale tilhørsforhold', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Kommunalttilhørsforhold';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver hvilket land personen har statsborgerskab i', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Statsborgerland';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver personens fødested', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Fødested';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver personens herkomst', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Herkomst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver om personen har beskyttet adresse eller ej', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'ErBeskyttet';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'ErUmyndig';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens Fars CPR nr.', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'PersonnummerFar';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personens Mors CPR nr.', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'PersonnummerMor';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver hvem der har forældremyndighed', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Forældremyndighed';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver om personen er medlem af folkekirken', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'Kirkeoplysning';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'GældendeFra';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'GældendeTil';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder nummeret på den kommune, som rækken tilhører', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_KommuneId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder information om, hvilken batch rækken er indlæst i', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_BatchDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder et fortløbende nummer, så alle rækker i tabellen har et unikt nummer', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_RowID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder det dato stempel, som kildefilen er markeret med', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysExecutionId', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_ExecutionId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'borger', 
@level0type = N'SCHEMA', @level0name = N'Borger', 
@level1type = N'TABLE',  @level1name = N'DimBorger';
GO

