我有一张订单表
Column | Type | Modifiers
------------+-----------------------------+-----------------------------------------------------
id | integer | not null default nextval('orders_id_seq'::regclass)
client_id | integer | not null
start_date | date | not null
end_date | date |
order_type | character varying | not null
Run Code Online (Sandbox Code Playgroud)
数据具有针对 client_id 的非重叠常规订单,并且偶尔会出现临时订单,当它们具有匹配的 client_id 时,会覆盖其 start_date 的常规订单。存在应用程序级别的限制,以防止相同类型的订单重叠。
id | client_id | start_date | end_date | order_type
----+-----------+------------+------------+------------
17 | 11 | 2014-02-05 | | standing
18 | 15 | 2014-07-16 | 2015-07-19 | standing
19 | 16 | 2015-04-01 | | standing …
Run Code Online (Sandbox Code Playgroud)