买方和卖方徽章分配模块数据库设计



我正在开发一个B2B交易应用程序,它有各种产品的买家和供应商。

我正在尝试开发一个"徽章分配模块",该模块将用于根据买家和供应商的验证、购买/销售强度、+ve 反馈等,通过管理面板将徽章分配给买家和供应商。用户可以获得一个或多个徽章。

分配的徽章应有有效期。请帮助我进行数据库设计 - 所需的表和列是什么?

请建议 asp.net 中是否有任何实现相同逻辑的开源/初学者工具包应用程序。

首先,买方和卖方应该在同一个表中,您应该使用表继承来对它们进行建模。

买家有许多徽章分配。

徽章也有许多徽章分配。

因此,这是一种多对多关系。

一方是否可以获得徽章,让它过期,然后再获得相同的徽章?

您的架构应如下所示:

create table party_type(
  id smallint primary key,
  description text not null
);
insert into party_type values (1, 'Buyer'), (2, 'Seller');    
create table party(
  id bigint identity primary key,
  type smallint not null references party_type (id),
  name text not null
);

create table badge(
  id bigint identity primary key,
  name text not null
);

create table party_badge(
  party_id bigint not null references party (id),
  badge_id bigint not null references badge (id),
  from_date datetime not null default current_timestamp,
  to_date datetime null default null,
  check (to_date > from_date),
  primary key (party_id, badge_id, from_date)
);

最新更新