【发布时间】:2021-11-22 02:09:47
【问题描述】:
我正在尝试在产品促销的 postgres 中创建一个表,这是一个简化的示例:
create table promotions
(
product_id text,
start_date date,
end_date date,
discount numeric(5, 4)
)
对于特定产品,不应有重叠的促销活动,即该表不应允许有两行相同的product_id 具有重叠的日期范围。
我不知道这是否可能,但我认为最好将其编码为约束。
我一直在寻找解决方案,但找不到任何人解决这个特定问题。
【问题讨论】:
标签: sql postgresql date constraints