Advertisement
KeeJayBe

Untitled

Mar 12th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. create table [DimCustomer](
  2. [CustomerKey] int identity(1,1) not null,
  3. [CustomerId] int not null,
  4. [CustomerEmail] nvarchar(50) not null,
  5. [CustomerContactTitle] nvarchar(5) not null,
  6. [CustomerFirstName] nvarchar(30) not null,
  7. [CustomerLastName] nvarchar(30) not null,
  8. [CustomerAddress] nvarchar(60) not null,
  9. [CustomerCity] nvarchar(30) not null,
  10. [CustomerCountry] nvarchar(30) not null,
  11. [CustomerPostalCode] nvarchar(30 not null,
  12. [CustomerPhone] nvarchar(20) not null,
  13. [Start] date not null,
  14. [End] date null,
  15. constraint PK_DimCustomer primary key ([CustomerKey])
  16. )
  17.  
  18. create table [DimBookedSeat](
  19. [BookedSeatKey] int not null,
  20. [BookedSeatId] int not null,
  21. [BookedSeatRowNr] int not null,
  22. [BookedSeatSeatNr] int not null,
  23. constraint PK_DimBookedSeat primary key ([BookedSeatKey])
  24. )
  25.  
  26. create table [DimGenre](
  27. [GenreKey] int not null,
  28. [GenreId] int not null,
  29. [GenreDescription] nvarchar(50),
  30. [GenreNrOfMovies] int,
  31. constraint PK_DimGenre primary key ([GenreKey])
  32. )
  33.  
  34. create table [DimMovie](
  35. [MovieKey] int not null,
  36. [MovieId] int not null,
  37. [MovieName] nvarchar(50) not null,
  38. constraint PK_DimMovie primary key ([MovieKey])
  39. )
  40.  
  41. /*create table [DimBooking](
  42. [BookingKey] int not null,
  43. [BookingId] int not null,
  44. [BookingDate] datetime not null,
  45. [ShowingDate] int not null,
  46. [BookingPaid] bit not null,
  47. constraint PK_DimBooking primary key ([BookingKey])
  48. )*/
  49.  
  50. CREATE TABLE [DimDate] (
  51. [DateKey] INT NOT NULL,
  52. [FullDateAlternateKey] DATE NOT NULL,
  53. [EnglishDayNameOfWeek] NVARCHAR(50) NOT NULL,
  54. [DutchDayNameOfWeek] NVARCHAR(50) NOT NULL,
  55. [MonthNumber] TINYINT NOT NULL,
  56. [EnglishMonthName] NVARCHAR(50) NOT NULL,
  57. [DutchMonthName] NVARCHAR(50) NOT NULL,
  58. [CalendarQuarter] TINYINT NOT NULL,
  59. [CalendarYear] SMALLINT NOT NULL
  60. CONSTRAINT PK_DimDate PRIMARY KEY(DateKey)
  61. )
  62.  
  63. /*create table [DimMovieShowing](
  64. [MovieShowingKey] int not null,
  65. [MovieShowingId] int not null,
  66. -- [ShowTime] time not null,
  67. -- [ShowDatesStart] date not null,
  68. -- [ShowDatesEnd] date not null,
  69. [MovieShowingPrice] float not null,
  70. constraint PK_DimMovieShowing primary key ([MovieShowingKey])
  71. )*/
  72.  
  73. create table [BookingFact](
  74. [CustomerKey] int not null,
  75. [DateKey] int not null,
  76. [MovieKey] int not null,
  77. [GenreKey] int not null,
  78. [UnitPrice] float not null,
  79. [BookedSeats] int not null,
  80. [Turnover] float not null,
  81.  
  82. constraint PK_BookingFact primary key ([CustomerKey], [MovieKey], [DateKey]),
  83.  
  84. constraint FK_DimMovie foreign key ([MovieKey])references DimMovie(MovieKey),
  85. constraint FK_DimCustomer foreign key ([CustomerKey]) references DimCustomer(CustomerKey),
  86. constraint FK_DimDate foreign key ([DateKey]) references DimDate(DateKey),
  87. constraint FK_DimGenre foreign key ([GenreKey]) references DimGenre(GenreKey)
  88. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement