Skip to content

Instantly share code, notes, and snippets.

@bitemyapp
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save bitemyapp/9629513 to your computer and use it in GitHub Desktop.

Select an option

Save bitemyapp/9629513 to your computer and use it in GitHub Desktop.
Database data structuring question

I need to normalize relative ordering of the contents of an array into something that can be efficiently indexed and queried against.

Given data: [".content", "blah", "woo"] that should be discovered by a query ".content" FOLLOWED_BY "woo"

Note the sparseness. It's contingent on the relative ordering of the elements, not the absolute values of the indexes.

I'm trying to figure out if there's a way to represent the relative ordering as neatly indexable, absolute values.

To index these relative positions I would have to index an explosion of paired off values. [".content", "blah", "woo"] would return into (".content", "blah", OBJ_ID), (".content", "woo", OBJ_ID), ("blah", "woo", OBJ_ID).

I need roughly (log n) access into a continually accumulated index of this data.

Can I normalize the relative ordering into an absolute space such that queries can be answered by a range query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment