MySQL :: Managing Hierarchical Data in MySQL

Mike Hillyer wrote a very good arti­cle on Man­ag­ing Hier­ar­chi­cal data in MySQL, defen­itely worth a read;

Most users at one time or another have dealt with hier­ar­chi­cal data in a SQL data­base and no doubt learned that the man­age­ment of hier­ar­chi­cal data is not what a rela­tional data­base is intended for. The tables of a rela­tional data­base are not hier­ar­chi­cal (like XML), but are sim­ply a flat list. Hier­ar­chi­cal data has a parent-child rela­tion­ship that is not nat­u­rally rep­re­sented in a rela­tional data­base table.

For our pur­poses, hier­ar­chi­cal data is a col­lec­tion of data where each item has a sin­gle par­ent and zero or more chil­dren (with the excep­tion of the root item, which has no par­ent). Hier­ar­chi­cal data can be found in a vari­ety of data­base appli­ca­tions, includ­ing forum and mail­ing list threads, busi­ness orga­ni­za­tion charts, con­tent man­age­ment cat­e­gories, and prod­uct cat­e­gories. For our pur­poses we will use the fol­low­ing prod­uct cat­e­gory hier­ar­chy from an fic­tional elec­tron­ics store:

via MySQL :: Man­ag­ing Hier­ar­chi­cal Data in MySQL.

Tags: ,

Leave a Comment

*

Get Adobe Flash playerPlugin by wpburn.com wordpress themes