Facet A : Subject A1 : Science A1.1 : Physics A1.1.1 : Optics Facet B : Grade Level B1 : High School B1.1 : 10th Grade
So, '10th grade optics' would be 'A1.1.1B1.1'. We use a delimitor between items, so we aren't restricted to subsets that each have a unique character in them, allowing for wider branching. (depth is still a problem when dealing with fixed line lengths)
The problem is, it's fine for humans to understand, but a little messy to sort on in SQL. You can get around this by adding another delimiter between facets, and ending every notation w/ a null heirarchy: ';A1.1.1.;B1.1.'. We can then get all items relating to 10th grade physics w/ LIKE '%;A1.1.%;B1.1.%', without fear of getting 'A1.10AB1.1', and still getting items that may have even more facets, eg a movie for 10th grade physics ';A1.1;B1.1;C1'
The only requirement is that you keep each of the facets in order. (what order doesn't matter, so long as you're consistent)
If you'd like a more complex example:
If we were to try to categorize cooking implements:
Facet A : Use A1 : Utensil A1.1 : Spoon A1.2 : Whisk A2 : Pan A2.1 : Roasting Pan A2.1.1 : Covered Roasting Pan A2.1.2 : Uncovered Roasting Pan Facet B : Material B1 : Metal B1.1 : Stainless Steel B1.2 : Aluminum B1.3 : Cast Iron B1.3.1 : Enameled Cast Iron B2 : Ceramic B2.1 : Glass B2.1.1 : Pyrex B2.2 : Stone Facet C : Size C1 : 1 qt C2 : 2 qt C2.1 : 2 qt, shallow
Therefore, a standard 9x13 pyrex dish would be ';A2.1.2.;B2.1.1.;C2.1.', and we could find all 2qt glass pans with '%;A2.%B2.1.%;C2.%'
In reply to Re^2: Trees in SQL, adjacency lists and sorting.
by jhourcle
in thread Trees in SQL, adjacency lists and sorting.
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |