hierarchy data model mysql store procedure implimentation