Created
January 25, 2022 19:37
-
-
Save mgramin/6f30d31bddcdd58dd648f232a5e29ce2 to your computer and use it in GitHub Desktop.
Relational Interval Tree Example
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
| CREATE TABLE test(text value, int node_id, int left_bound_id, int right_bound_id); | |
| INSERT INTO test VALUES ('Food', 0, 1, 10000); | |
| INSERT INTO test VALUES ('Fruit', 100, 101, 199); | |
| INSERT INTO test VALUES ('Cherry', 101, null, null); | |
| INSERT INTO test VALUES ('Banana', 102, null, null); | |
| INSERT INTO test VALUES ('Meat', 200, 201, 299); | |
| INSERT INTO test VALUES ('Beaf', 201, null, null); | |
| INSERT INTO test VALUES ('Pork', 202, null, null); | |
| -- get all fruits | |
| SELECT value FROM tests WHERE node_id between 101 and 199; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment