Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. CREATE TABLE [dbo].[TopicKeyword] (
  2. [Id] SMALLINT NOT NULL,
  3. [Keyword] VARCHAR (100) NOT NULL,
  4. [Volume] INT NOT NULL,
  5. [PageId] SMALLINT NOT NULL,
  6. CONSTRAINT [PK_TopicKeyword] PRIMARY KEY CLUSTERED ([Id] ASC),
  7. CONSTRAINT [AK_TopicKeyword_Keyword] UNIQUE NONCLUSTERED ([Keyword] ASC),
  8. CONSTRAINT [FK_TopicKeyword_PageMeta] FOREIGN KEY ([PageId]) REFERENCES [dbo].[PageMeta] ([Id])
  9. );
  10.  
  11. GO
  12. CREATE NONCLUSTERED INDEX [IX_TopicKeyword_PageId]
  13. ON [dbo].[TopicKeyword]([PageId] ASC);
  14.  
  15. GO
  16. CREATE UNIQUE NONCLUSTERED INDEX [IX_TopicKeyword_Id_PageId]
  17. ON [dbo].[TopicKeyword]([Id] ASC, [PageId] ASC);
  18.  
  19. CREATE TABLE [dbo].[TopicContent] (
  20. [ParentKeywordId] SMALLINT NOT NULL,
  21. [KeywordId] SMALLINT NOT NULL,
  22. CONSTRAINT [PK_TopicContent] PRIMARY KEY CLUSTERED ([ParentKeywordId] ASC, [KeywordId] ASC),
  23. CONSTRAINT [FK_TopicContent_TopicCluster] FOREIGN KEY ([ParentKeywordId]) REFERENCES [dbo].[TopicCluster] ([KeywordId]),
  24. CONSTRAINT [FK_TopicContent_TopicKeyword] FOREIGN KEY ([KeywordId]) REFERENCES [dbo].[TopicKeyword] ([Id]),
  25. CONSTRAINT [CK_TopicContent_ParentKeywordId] CHECK ([ParentKeywordId]<>[KeywordId])
  26. );
  27.  
  28. GO
  29. CREATE NONCLUSTERED INDEX [IX_TopicContent_KeywordId]
  30. ON [dbo].[TopicContent]([KeywordId] ASC);
  31.  
  32. CREATE TABLE [dbo].[TopicCluster] (
  33. [KeywordId] SMALLINT NOT NULL,
  34. [PageId] SMALLINT NOT NULL,
  35. CONSTRAINT [PK_TopicCluster] PRIMARY KEY CLUSTERED ([KeywordId] ASC),
  36. CONSTRAINT [AK_TopicCluster_PageId] UNIQUE NONCLUSTERED ([PageId] ASC),
  37. CONSTRAINT [FK_TopicCluster_TopicKeyword] FOREIGN KEY ([KeywordId]) REFERENCES [dbo].[TopicKeyword] ([Id]),
  38. CONSTRAINT [FK_TopicCluster_TopicKeyword2] FOREIGN KEY ([KeywordId], [PageId]) REFERENCES [dbo].[TopicKeyword] ([Id], [PageId])
  39. );
  40.  
  41. GO
  42. CREATE NONCLUSTERED INDEX [IX_TopicCluster_KeywordId_PageId]
  43. ON [dbo].[TopicCluster]([KeywordId] ASC, [PageId] ASC);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement