====intervals====
id
company_id: INT
start: DATETIME
end: DATETIME
type_id: Foreign key to events
====events====
id: PK
type_name: CHAR
is_work_time: BOOLEAN
…
Запрос будет примерно такой:
SELECT TIMEDIFF(end, start) as diff FROM intervals SORT BY diff;