Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Proper siblings sorting in nested sets model

Re: Proper siblings sorting in nested sets model

From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 10 Apr 2004 20:27:13 -0700
Message-ID: <8a529bb.0404101927.5b564737@posting.google.com>


pacha_shevaev_at_mail.ru (Pavel Schevaev) wrote in message news:<320b3b2.0404100113.1ebe509b_at_posting.google.com>...
>
> LEVEL IDENTIFIER CLASS CLASS_ORDR CLASS_ID
> ----- -------------------- ---------- ----------- --------
> 1 KING CONTAINER 0 1
> 2 A-FILES FILES_FOLDER 0 2
> 3 A-FILES FILES_FOLDER 0 2
> 3 B-FILES FILES_FOLDER 0 2
> 3 F1 FILE 1 3
> 3 F2 FILE 1 3
> 3 F3 FILE 1 3
> 2 B-DOCS DOCUMENTS_FOLDER 0 7
> 3 D1 DOCUMENT 1 4
> 2 C-IMAGES IMAGES_FOLDER 0 5
> 3 A-IMAGES IMAGES_FOLDER 0 5
> 4 SMITH IMAGE 1 6
> 3 B-IMAGES IMAGES_FOLDER 0 5
> 4 ADAMS IMAGE 1 6
>
> 1) we have TREE table where the nested sets structure
> resides(IDENTIFIER is stored in this table)
> 2) we also have CLASS table which is in one-to-many with TREE table on
> CLASS_ID attribute, this table has CLASS_ORDR field that defines order
> of siblings
>
> So siblings are ordered by CLASS_ORDR and by IDENTIFIER.
> (in short it looks just like a file system in your Total Commander,
> Midnight Commander, FAR etc.)

Why your example is not ordered by paths

KING

KING.A-FILES
KING.A-FILES.A-FILES
KING.A-FILES.B-FILES

...

? Whatever function you use for sibling ordering should work for concatenated path ordering, right?

I missed a minor detail in my post. What if you have 2 KINGs at the same level? Easy: just concatenate whatever sort criteria you use with unique node identifier, say lft:

KING1

KING1.A-FILES2
KING1.A-FILES2.A-FILES3
KING1.A-FILES2.B-FILES7

... Received on Sat Apr 10 2004 - 22:27:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US