3 ms·
I'm always impressed by the PostgreSQL team. Personally, I'm excited about the range types and I can see immediate usefulness for them. My own applications asi
by EvanAnderson 14y ago
I'm always impressed by the PostgreSQL team.
Personally, I'm excited about the range types and I can see immediate usefulness for them. My own applications aside, anything that helps developers create schemas that are better able to handle temporal data is a good thing.
- r4vik 14y agoalso overlooked is the massive speed improvement for in memory sorting.. that's what I've been waiting for.
- jeltz 14y agoRange types combined with exclusion constraints solve the problem of not allowing overlapping bookings using a database constraint. The solution is simple, clean, and flexible unlike the workarounds. Example of adding such a constraint: ALTER TABLE reservation ADD EXCLUDE USING gist (room WITH =, during WITH &&); In this example a room cannot be double booked. EDIT: This is a feature entirely unique to PostgreSQL.
- jeffdavis 14y agoI'll be speaking on this use case next week at Postgres Open ( http://postgresopen.org http://postgresopen.org ) as part of a larger demo of temporal databases in postgresql. Jonathan S. Katz will also be presenting on Range Types.
- joevandyk 14y agoFor example: if you have a coupon that has a start and end time (but the end time is optional), typically, you'd have a start_at and end_at datetime columns. The query for checking for an active coupon would be: select * from coupons where start_at < now() and (end_at is null or end_at > now()) Now, you can have a single column that represents the range of time that the coupon is active. select * from coupons where now() <@ duration; Plus, exclusion contraints. So you could prevent the database from storing a coupon that was active at the same time as another coupon.