2 ms·
But beware of what may happen when you get over 9: 1 1.1 1.2 10 2 2.1 To support that, you will have to be careful when picking collation order, a
by Someone 12y ago
But beware of what may happen when you get over 9:
1
1.1
1.2
10
2
2.1
To support that, you will have to be careful when picking collation order, and binary collation will not do it. It may be better to use fixed-width numbers with leading zeroes instead, but that, of course, may unnecessarily grow the space used by the table.
And of course, that also is what RCS and SCCS use for numbering revisions.
- bojanz 12y agoI've done research on this and other problems, based on Drupal's solutions: https://bojanz.wordpress.com/2014/04/25/storing-hierarchical-data-materialized-path/ https://bojanz.wordpress.com/2014/04/25/storing-hierarchical...
- Retra 12y agoOr use your decimal as a place extension instead of a hierarchal separator. Your tree would look like this: 1 11 12 1.0 2 21 Then you just ensure that '.' sorts after all digits. (Probably by using a different symbol.) Basically, the '.' means "insert after."
- ketralnis 12y agoIn postgres specifically you can use an int array field rather than a string