Advertisement
Guest User

Création DB dimensionnelle v2

a guest
Nov 9th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.65 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.     [Date] [datetime] NOT NULL,
  12.  CONSTRAINT [PK_DimDate] PRIMARY KEY CLUSTERED
  13. (
  14.     [DateKey] ASC
  15. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  16. ) ON [PRIMARY]
  17.  
  18. GO
  19. /****** Object:  Table [dbo].[FactPost]    Script Date: 26-10-17 09:50:18 ******/
  20. SET ANSI_NULLS ON
  21. GO
  22. SET QUOTED_IDENTIFIER ON
  23. GO
  24. CREATE TABLE [dbo].[FactPost](
  25.     [DateCreatedKey] [int] NOT NULL,
  26.     [Score] [int] NOT NULL,
  27.     [FavoriteCount] [int] NOT NULL,
  28.     [ViewCount] [int] NOT NULL,
  29.     [AnswerCount] [int] NOT NULL,
  30.     [PostKey] [bigint] IDENTITY(1,1) NOT NULL,
  31.     [DateClosedKey] [int] NOT NULL,
  32.  CONSTRAINT [PK_FactPost] PRIMARY KEY CLUSTERED
  33. (
  34.     [PostKey] ASC
  35. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  36. ) ON [PRIMARY]
  37.  
  38. GO
  39. ALTER TABLE [dbo].[FactPost]  WITH CHECK ADD  CONSTRAINT [FK_FactPost_DimDate] FOREIGN KEY([DateCreatedKey])
  40. REFERENCES [dbo].[DimDate] ([DateKey])
  41. GO
  42. ALTER TABLE [dbo].[FactPost] CHECK CONSTRAINT [FK_FactPost_DimDate]
  43. GO
  44. ALTER TABLE [dbo].[FactPost]  WITH CHECK ADD  CONSTRAINT [FK_FactPost_DimDate1] FOREIGN KEY([DateClosedKey])
  45. REFERENCES [dbo].[DimDate] ([DateKey])
  46. GO
  47. ALTER TABLE [dbo].[FactPost] CHECK CONSTRAINT [FK_FactPost_DimDate1]
  48. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement