1つは、買い手と売り手が同じテーブルに存在する必要があり、テーブルの継承を使用してそれらをモデル化する必要があります。
バイヤーには多くのバッジが割り当てられています。
バッジにも多くのバッジ割り当てがあります。
したがって、それは多対多の関係です。
パーティーはバッジを取得し、有効期限が切れてから、後で同じバッジを再度取得できますか?
スキーマは次のようになります。
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)
);