我有以下SQL Server数据库架构:
CREATE TABLE [BlogEntries]
(
[Id] uniqueidentifier NOT NULL
, [Header] nvarchar(150) NOT NULL
, [HeaderUrl] nvarchar(160) NOT NULL
, [Author] nvarchar(100) NULL
, [ShortContent] nvarchar(1500) NOT NULL
, [Content] nvarchar(MAX) NULL
, [Visits] int NOT NULL
, [Visible] bit NOT NULL
, [PublishDate] datetime NOT NULL
, [Created] datetime NOT NULL
, [Modified] datetime NULL
);
GO
CREATE TABLE [BlogEntryComments]
(
[Id] uniqueidentifier NOT NULL
, [Name] nvarchar(50) NOT NULL
, [Comment] nvarchar(2500) NOT NULL
, [Email] nvarchar(50) NULL
, [Homepage] nvarchar(100) NULL
, [AdminPost] bit NOT NULL
, [BlogEntryId] uniqueidentifier NOT NULL
, [Created] datetime NOT NULL
, [Modified] datetime NULL
);
GO
ALTER TABLE [BlogEntries]
ADD CONSTRAINT [PK_dbo.BlogEntries] PRIMARY KEY ([Id]);
GO
ALTER TABLE [BlogEntryComments]
ADD CONSTRAINT [PK_dbo.BlogEntryComments] PRIMARY KEY ([Id]);
GO
ALTER TABLE [BlogEntryComments]
ADD CONSTRAINT [FK_dbo.BlogEntryComments_dbo.BlogEntries_BlogEntryId]
FOREIGN KEY ([BlogEntryId]) REFERENCES [BlogEntries]([Id])
ON DELETE CASCADE ON UPDATE NO ACTION;
GO
我需要为当前的数据库实现一个回复模式。基本上,用户应该能够回复评论,并且该回复应该与已经回复的特定评论相关联。
我该怎么做?
我想在BlogEntryComments中添加另一个名为ParentComment
的字段,并添加回复的父评论的ID?还有其他建议吗?