mysql - Hierarchical Query Advantages -


i have huge database tables filled scientific names, in parent-child relationship, this...

taxon | parent mammalia | chordata carnivora | mammalia canidae | carnivora canis | canidae canis-lupus | canis 

i installed postgresql , started working on hierarchical query, it's far more complex thought. i'm thinking of sticking mysql , going original scheme, looks this:

taxon | parent | family | order mammalia | chordata | (null) | (null) carnivora | mammalia | (null) | carnivora canidae | carnivora | canidae | carnivora canis | canidae | canidae | carnivora canis-lupus | canis | canidae | carnivora 

it looks amateurish, surprised discover catalogue of life apparently uses same scheme, more columns , on million rows.

with scheme, can count children , grandchildren counting number of species match table.family > canidae, example. , can use series of "stairstep" queries figure out names of great grandparents, etc.

so wondered benefits of hierarchical queries are. they're more elegant, , can presumably 1 or 2 queries, rather series of queries. assume they're faster, though original query, 2 fields, fast enough.

do hierarchical queries have additional significant advantage justify me hiring set 1 up, or matter of speed?

if hierarchical queries, mean postgresql common table expressions; answer wonderfull feature allow write more readable queries , in (but not all) cases lead improved performance.

is worth hiring install postgresql you? maybe, maybe not. it's hard without benchmarks.

what ought try: modified pre order tree traversal sounds complicated, isn't

we’ll start laying out our tree in horizontal way. start @ root node (‘food’), , write 1 left. follow tree ‘fruit’ , write 2 next it. in way, walk (traverse) along edges of tree while writing number on left , right side of each node. last number written @ right side of ‘food’ node. in image, can see whole numbered tree, , few arrows indicate numbering order.

here excellent article on it. http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

this approach can used in both postgreql , mysql , existing data can converted without difficulty.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -