FoghornModel.edmx.sql 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. -- --------------------------------------------------
  2. -- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
  3. -- --------------------------------------------------
  4. -- Date Created: 02/15/2013 18:45:53
  5. -- Generated from EDMX file: C:\Development\Foghorn\Foghorn.Core\FoghornModel.edmx
  6. -- --------------------------------------------------
  7. SET QUOTED_IDENTIFIER OFF;
  8. GO
  9. USE [Foghorn];
  10. GO
  11. IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
  12. GO
  13. -- --------------------------------------------------
  14. -- Dropping existing FOREIGN KEY constraints
  15. -- --------------------------------------------------
  16. IF OBJECT_ID(N'[dbo].[FK_SubscriberNotification_Subscriber]', 'F') IS NOT NULL
  17. ALTER TABLE [dbo].[SubscriberNotification] DROP CONSTRAINT [FK_SubscriberNotification_Subscriber];
  18. GO
  19. IF OBJECT_ID(N'[dbo].[FK_SubscriberNotification_Notification]', 'F') IS NOT NULL
  20. ALTER TABLE [dbo].[SubscriberNotification] DROP CONSTRAINT [FK_SubscriberNotification_Notification];
  21. GO
  22. IF OBJECT_ID(N'[dbo].[FK_SendingApplicationSubscriber]', 'F') IS NOT NULL
  23. ALTER TABLE [dbo].[Subscribers] DROP CONSTRAINT [FK_SendingApplicationSubscriber];
  24. GO
  25. IF OBJECT_ID(N'[dbo].[FK_NotificationNotificationType]', 'F') IS NOT NULL
  26. ALTER TABLE [dbo].[Notifications] DROP CONSTRAINT [FK_NotificationNotificationType];
  27. GO
  28. IF OBJECT_ID(N'[dbo].[FK_SendingApplicationNotificationType]', 'F') IS NOT NULL
  29. ALTER TABLE [dbo].[NotificationTypes] DROP CONSTRAINT [FK_SendingApplicationNotificationType];
  30. GO
  31. -- --------------------------------------------------
  32. -- Dropping existing tables
  33. -- --------------------------------------------------
  34. IF OBJECT_ID(N'[dbo].[Subscribers]', 'U') IS NOT NULL
  35. DROP TABLE [dbo].[Subscribers];
  36. GO
  37. IF OBJECT_ID(N'[dbo].[Notifications]', 'U') IS NOT NULL
  38. DROP TABLE [dbo].[Notifications];
  39. GO
  40. IF OBJECT_ID(N'[dbo].[SendingApplications]', 'U') IS NOT NULL
  41. DROP TABLE [dbo].[SendingApplications];
  42. GO
  43. IF OBJECT_ID(N'[dbo].[NotificationTypes]', 'U') IS NOT NULL
  44. DROP TABLE [dbo].[NotificationTypes];
  45. GO
  46. IF OBJECT_ID(N'[dbo].[SubscriberNotification]', 'U') IS NOT NULL
  47. DROP TABLE [dbo].[SubscriberNotification];
  48. GO
  49. -- --------------------------------------------------
  50. -- Creating all tables
  51. -- --------------------------------------------------
  52. -- Creating table 'Subscribers'
  53. CREATE TABLE [dbo].[Subscribers] (
  54. [SubscriberId] uniqueidentifier NOT NULL,
  55. [SubscriberName] nvarchar(255) NOT NULL,
  56. [Port] int NULL,
  57. [HostName] nvarchar(255) NOT NULL,
  58. [Password] nvarchar(20) NOT NULL,
  59. [SendingApplication_SendingApplicationId] int NOT NULL
  60. );
  61. GO
  62. -- Creating table 'Notifications'
  63. CREATE TABLE [dbo].[Notifications] (
  64. [NotificationId] int IDENTITY(1,1) NOT NULL,
  65. [NotificationTitle] nvarchar(max) NOT NULL,
  66. [NotificationMessage] nvarchar(max) NOT NULL,
  67. [SentDateTime] datetime NOT NULL,
  68. [Priority] int NOT NULL,
  69. [Sticky] bit NOT NULL,
  70. [NotificationType_NotificationTypeId] int NOT NULL
  71. );
  72. GO
  73. -- Creating table 'SendingApplications'
  74. CREATE TABLE [dbo].[SendingApplications] (
  75. [SendingApplicationId] int IDENTITY(1,1) NOT NULL,
  76. [SendingApplicationName] nvarchar(255) NOT NULL,
  77. [SendingApplicationIcon] varbinary(max) NULL
  78. );
  79. GO
  80. -- Creating table 'NotificationTypes'
  81. CREATE TABLE [dbo].[NotificationTypes] (
  82. [NotificationTypeId] int IDENTITY(1,1) NOT NULL,
  83. [NotificationTypeName] nvarchar(32) NOT NULL,
  84. [NotificationTypeDisplayName] nvarchar(255) NOT NULL,
  85. [NotificationTypeIcon] varbinary(max) NULL,
  86. [SendingApplication_SendingApplicationId] int NOT NULL
  87. );
  88. GO
  89. -- Creating table 'SubscriberNotification'
  90. CREATE TABLE [dbo].[SubscriberNotification] (
  91. [SentToSubscribers_SubscriberId] uniqueidentifier NOT NULL,
  92. [NotificationsSent_NotificationId] int NOT NULL
  93. );
  94. GO
  95. -- --------------------------------------------------
  96. -- Creating all PRIMARY KEY constraints
  97. -- --------------------------------------------------
  98. -- Creating primary key on [SubscriberId] in table 'Subscribers'
  99. ALTER TABLE [dbo].[Subscribers]
  100. ADD CONSTRAINT [PK_Subscribers]
  101. PRIMARY KEY CLUSTERED ([SubscriberId] ASC);
  102. GO
  103. -- Creating primary key on [NotificationId] in table 'Notifications'
  104. ALTER TABLE [dbo].[Notifications]
  105. ADD CONSTRAINT [PK_Notifications]
  106. PRIMARY KEY CLUSTERED ([NotificationId] ASC);
  107. GO
  108. -- Creating primary key on [SendingApplicationId] in table 'SendingApplications'
  109. ALTER TABLE [dbo].[SendingApplications]
  110. ADD CONSTRAINT [PK_SendingApplications]
  111. PRIMARY KEY CLUSTERED ([SendingApplicationId] ASC);
  112. GO
  113. -- Creating primary key on [NotificationTypeId] in table 'NotificationTypes'
  114. ALTER TABLE [dbo].[NotificationTypes]
  115. ADD CONSTRAINT [PK_NotificationTypes]
  116. PRIMARY KEY CLUSTERED ([NotificationTypeId] ASC);
  117. GO
  118. -- Creating primary key on [SentToSubscribers_SubscriberId], [NotificationsSent_NotificationId] in table 'SubscriberNotification'
  119. ALTER TABLE [dbo].[SubscriberNotification]
  120. ADD CONSTRAINT [PK_SubscriberNotification]
  121. PRIMARY KEY NONCLUSTERED ([SentToSubscribers_SubscriberId], [NotificationsSent_NotificationId] ASC);
  122. GO
  123. -- --------------------------------------------------
  124. -- Creating all FOREIGN KEY constraints
  125. -- --------------------------------------------------
  126. -- Creating foreign key on [SentToSubscribers_SubscriberId] in table 'SubscriberNotification'
  127. ALTER TABLE [dbo].[SubscriberNotification]
  128. ADD CONSTRAINT [FK_SubscriberNotification_Subscriber]
  129. FOREIGN KEY ([SentToSubscribers_SubscriberId])
  130. REFERENCES [dbo].[Subscribers]
  131. ([SubscriberId])
  132. ON DELETE NO ACTION ON UPDATE NO ACTION;
  133. GO
  134. -- Creating foreign key on [NotificationsSent_NotificationId] in table 'SubscriberNotification'
  135. ALTER TABLE [dbo].[SubscriberNotification]
  136. ADD CONSTRAINT [FK_SubscriberNotification_Notification]
  137. FOREIGN KEY ([NotificationsSent_NotificationId])
  138. REFERENCES [dbo].[Notifications]
  139. ([NotificationId])
  140. ON DELETE NO ACTION ON UPDATE NO ACTION;
  141. -- Creating non-clustered index for FOREIGN KEY 'FK_SubscriberNotification_Notification'
  142. CREATE INDEX [IX_FK_SubscriberNotification_Notification]
  143. ON [dbo].[SubscriberNotification]
  144. ([NotificationsSent_NotificationId]);
  145. GO
  146. -- Creating foreign key on [SendingApplication_SendingApplicationId] in table 'Subscribers'
  147. ALTER TABLE [dbo].[Subscribers]
  148. ADD CONSTRAINT [FK_SendingApplicationSubscriber]
  149. FOREIGN KEY ([SendingApplication_SendingApplicationId])
  150. REFERENCES [dbo].[SendingApplications]
  151. ([SendingApplicationId])
  152. ON DELETE CASCADE ON UPDATE NO ACTION;
  153. -- Creating non-clustered index for FOREIGN KEY 'FK_SendingApplicationSubscriber'
  154. CREATE INDEX [IX_FK_SendingApplicationSubscriber]
  155. ON [dbo].[Subscribers]
  156. ([SendingApplication_SendingApplicationId]);
  157. GO
  158. -- Creating foreign key on [NotificationType_NotificationTypeId] in table 'Notifications'
  159. ALTER TABLE [dbo].[Notifications]
  160. ADD CONSTRAINT [FK_NotificationNotificationType]
  161. FOREIGN KEY ([NotificationType_NotificationTypeId])
  162. REFERENCES [dbo].[NotificationTypes]
  163. ([NotificationTypeId])
  164. ON DELETE NO ACTION ON UPDATE NO ACTION;
  165. -- Creating non-clustered index for FOREIGN KEY 'FK_NotificationNotificationType'
  166. CREATE INDEX [IX_FK_NotificationNotificationType]
  167. ON [dbo].[Notifications]
  168. ([NotificationType_NotificationTypeId]);
  169. GO
  170. -- Creating foreign key on [SendingApplication_SendingApplicationId] in table 'NotificationTypes'
  171. ALTER TABLE [dbo].[NotificationTypes]
  172. ADD CONSTRAINT [FK_SendingApplicationNotificationType]
  173. FOREIGN KEY ([SendingApplication_SendingApplicationId])
  174. REFERENCES [dbo].[SendingApplications]
  175. ([SendingApplicationId])
  176. ON DELETE CASCADE ON UPDATE NO ACTION;
  177. -- Creating non-clustered index for FOREIGN KEY 'FK_SendingApplicationNotificationType'
  178. CREATE INDEX [IX_FK_SendingApplicationNotificationType]
  179. ON [dbo].[NotificationTypes]
  180. ([SendingApplication_SendingApplicationId]);
  181. GO
  182. -- --------------------------------------------------
  183. -- Script has ended
  184. -- --------------------------------------------------