简体   繁体   English

存储具有交集约束的时间范围的最佳方法?

[英]Best way to store time ranges with intersection constraint?

I'm trying to implement timetable, with business hours.我正在尝试实施时间表,包括营业时间。 What is the best way to store time ranges (eg 12:00-14:00) from lower bound to upper (24h), with intersection check, eg for object_id = 1 and day_of_the_week = 1, there can not be intersections in any provided intervals.存储从下限到上限(24 小时)的时间范围(例如 12:00-14:00)的最佳方法是什么,使用交集检查,例如对于object_id = 1 和day_of_the_week = 1,任何提供的都不能有交集间隔。

Use an Exclusion Constraint :使用排除约束

EXCLUDE USING gist (object_id WITH =, day_of_the_week WITH =, time_range WITH &&)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM