Advertisement
Guest User

T-SQL DB Dimensionnelle Labo BI ETL Commun

a guest
Oct 17th, 2018
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.63 KB | None | 0 0
  1. USE XXXXX;
  2. CREATE TABLE [dbo].[DimDate](
  3.     [DateKey] [int] NOT NULL,
  4.     [DayFrenchName] [nvarchar](100) NOT NULL,
  5.     [DayEnglishName] [nvarchar](100) NOT NULL,
  6.     [MonthFrenchName] [nvarchar](100) NOT NULL,
  7.     [MonthEnglishName] [nvarchar](100) NOT NULL,
  8.     [WeekNumber] [int] NOT NULL,
  9.     [DayOfWeekNumber] [int] NOT NULL,
  10.     [DayOfYearNumber] [int] NOT NULL,
  11.  CONSTRAINT [PK_DimDate] PRIMARY KEY CLUSTERED
  12. (
  13.     [DateKey] ASC
  14. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  15. ) ON [PRIMARY]
  16.  
  17. GO
  18. /****** Object:  Table [dbo].[FactPost]    Script Date: 26-10-17 09:50:18 ******/
  19. SET ANSI_NULLS ON
  20. GO
  21. SET QUOTED_IDENTIFIER ON
  22. GO
  23. CREATE TABLE [dbo].[FactPost](
  24.     [DateCreatedKey] [int] NOT NULL,
  25.     [Score] [int] NOT NULL,
  26.     [FavoriteCount] [int] NOT NULL,
  27.     [ViewCount] [int] NOT NULL,
  28.     [AnswerCount] [int] NOT NULL,
  29.     [PostKey] [bigint] IDENTITY(1,1) NOT NULL,
  30.     [DateClosedKey] [int] NOT NULL,
  31.  CONSTRAINT [PK_FactPost] PRIMARY KEY CLUSTERED
  32. (
  33.     [PostKey] ASC
  34. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  35. ) ON [PRIMARY]
  36.  
  37. GO
  38. ALTER TABLE [dbo].[FactPost]  WITH CHECK ADD  CONSTRAINT [FK_FactPost_DimDate] FOREIGN KEY([DateCreatedKey])
  39. REFERENCES [dbo].[DimDate] ([DateKey])
  40. GO
  41. ALTER TABLE [dbo].[FactPost] CHECK CONSTRAINT [FK_FactPost_DimDate]
  42. GO
  43. ALTER TABLE [dbo].[FactPost]  WITH CHECK ADD  CONSTRAINT [FK_FactPost_DimDate1] FOREIGN KEY([DateClosedKey])
  44. REFERENCES [dbo].[DimDate] ([DateKey])
  45. GO
  46. ALTER TABLE [dbo].[FactPost] CHECK CONSTRAINT [FK_FactPost_DimDate1]
  47. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement