博客 post 修订版数据库设计
Blog post revisions with moderation step database design
我正在尝试为博客 post 设计一个数据库,可以对其进行修改并显示修订中的差异。通常,流程如下所示:
- 创建模板post。 (草稿状态随时更新)
- 完成模板后,您可以将其传递给审核。
- 主持人可以批准或拒绝您的post(提供原因)。
- 如果审核通过,则 post 已发布并可供用户查看。
- 如果 post 被拒绝,您可以申请新版本进行审核。
- 当 post 已经发布时,您可以通过新版本对其进行修改(也有审核阶段)。
我当前的文章数据库架构如下所示:
而且还不能满足我的要求。我不知道如何在数据库中模拟审核过程,以及可能的拒绝原因。那么考虑到所有这些,最好的方法是什么?
根据你在评论中提出的问题,我会像这样构建评论历史:
create table article_review_status (
article_review_status_id int generated always as identity,
status_code text not null unique
);
create table article_review (
article_review_id int generated always as identity,
article_revision_id int not null
references article_revision(article_revision_id),
article_review_status_id int not null
references article_review_status(article_review_status_id),
entry_at timestamptz not null default now(),
article_review_comments text,
reviewer_id int not null
references users(user_id) -- <-- Would this be another author or an admin?
);
然后您的应用程序可以确定是否使 article
可见。
我正在尝试为博客 post 设计一个数据库,可以对其进行修改并显示修订中的差异。通常,流程如下所示:
- 创建模板post。 (草稿状态随时更新)
- 完成模板后,您可以将其传递给审核。
- 主持人可以批准或拒绝您的post(提供原因)。
- 如果审核通过,则 post 已发布并可供用户查看。
- 如果 post 被拒绝,您可以申请新版本进行审核。
- 当 post 已经发布时,您可以通过新版本对其进行修改(也有审核阶段)。
我当前的文章数据库架构如下所示:
而且还不能满足我的要求。我不知道如何在数据库中模拟审核过程,以及可能的拒绝原因。那么考虑到所有这些,最好的方法是什么?
根据你在评论中提出的问题,我会像这样构建评论历史:
create table article_review_status (
article_review_status_id int generated always as identity,
status_code text not null unique
);
create table article_review (
article_review_id int generated always as identity,
article_revision_id int not null
references article_revision(article_revision_id),
article_review_status_id int not null
references article_review_status(article_review_status_id),
entry_at timestamptz not null default now(),
article_review_comments text,
reviewer_id int not null
references users(user_id) -- <-- Would this be another author or an admin?
);
然后您的应用程序可以确定是否使 article
可见。