1

我正在开发一个B2B交易应用程序,它有各种产品的买家和供应商。买家和卖家徽章分配模块数据库设计

我想开发将使用根据自己的验证,购买/卖出力量通过管理面板的采购商和供应商指定的徽章“徽章分配模块”,阳离子反馈等。用户可以获得一个或多个徽章。

分配的徽章应该有失效日期。请帮助我进行数据库设计 - 将要求的表和列是什么?

请建议在asp.net中是否有任何开源/入门套件应用程序正在实施相同的逻辑。

回答

0

其中之一,买方和卖方应该在同一张表中,你应该使用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) 
);