Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> PS/SQL for constructing binary tree for pedigree?
I'm about to start writing an Oracle app for a horse breed society stud book. One of the things I need to do is to be able to construct a pedigree chart going back a given number of generations. Thus, each horse record will have a mother and a father field, each of which references the PK of another horse record. If the mother and/or father is unknown the appropriate field will be NULL.
What I need is to take as input the maximum number of generations to trace back, and construct a binary tree of the ancestors of the horse going back that number of generations by recursively getting the parents of the previous generations.
Before I sit down and try and code something up myself, doesn anybody have a routine that will do this sort of thing or perhaps a reference for an appropriate algorithm?
-- James "I'd rather fall off Ilustrada than ride any other horse" PettsReceived on Fri Dec 05 1997 - 00:00:00 CST