【问题标题】:Buyer and Seller badge assignment module database design买卖双方徽章分配模块数据库设计
【发布时间】:2012-10-03 03:51:36
【问题描述】:
我正在开发一个 B2B 交易应用程序,它有各种产品的买家和供应商。
我正在尝试开发一个“徽章分配模块”,该模块将用于根据买家和供应商的验证、购买/销售实力、+ve 反馈等情况,通过管理面板将徽章分配给他们。用户可以获得一个或多个徽章。
分配的徽章应该有一个有效期。请帮助我进行数据库设计 - 所需的表和列是什么?
请建议在 asp.net 中是否有任何开源/入门工具包应用程序正在实现相同的逻辑。
【问题讨论】:
标签:
database-design
application-design
web-application-design
【解决方案1】:
首先,买家和卖家应该在同一个表中,您应该使用table inheritance 对其进行建模。
买家有许多徽章分配。
徽章也有许多徽章分配。
因此它是多对多的关系。
派对能否获得徽章,让它过期,然后再获得相同的徽章,稍后?
您的架构应如下所示:
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)
);