我有一个表reservation的列roomno(INTEGER),startdate(DATE),enddate(DATE)与主键(roomno, startdate)。
我如何在表上设置约束,以便不允许预订重叠?
我试图在SQLFIDDLE postgreSQL9.3 中实现这个
例如:
101 2016-01-01 2016-01-05
101 2016-01-03 2016-01-06 [This row should not be possible to insert]
Run Code Online (Sandbox Code Playgroud)
startdate并且enddate是数据类型date。
postgresql database-design exclusion-constraint postgresql-9.3 range-types