私のデータベース構造は次のとおりです。
授業時間のあるスケジュールがあります。各スケジュール時間には、期間を持つtclassが関連付けられています。私は通常、ある種の結合を使用して期間を取得しますが、postgresでオーバーラップ比較を使用しているため、これが可能かどうかはわかりません。クエリは次のようになります...
Select (scheduletimes.classtime, scheduletimes.classtime + interval
(select duration from tclasses where tclass.id = scheduletimes.tclass_id) minutes) OVERLAPS
(06:50:00, 07:20:00) from schedules where
day = 1 and
schedule_id = 14;