Created
February 15, 2016 00:17
-
-
Save warewolf/e600027a0884c8cdc65c to your computer and use it in GitHub Desktop.
Have a data model/query queston
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Okay, so I have a set of ranges. In the end these will be dates, but for sake of simplicity they're just numbers here. I think I'll be storing epoch dates. | |
| 10-100 | |
| 30-40 | |
| 35-60 | |
| 47-80 | |
| 12-90 | |
| Somebody is going to say "GRAPH DATABASE", but reall what I want is something akin to an index in a SQL db that I can query against ala a where clause. | |
| I have number 36. How do I store, let alone query *quickly* "Show me all ranges that cross 36?" (the vertical line below) | |
| 10---|--------100 | |
| 30-|40 | |
| 35|--60 | |
| 47-80 | |
| 12--|-------90 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a reason (as @bamapookie above said) that you couldn't just store the start and end of ranges? Index them (separately, or in this case I guess no reason not to index them together) and query where start <= $x and $x <= end. Not sure if between() behaves differently with indexes, but if not, then use that.