I've been developing an "advanced query builder" tool recently, and now I have a big problem with SQL generation algorithm.
Imagine Query graph with tables and Join links between them (just like query design view in MS Access). According to this scheme I have to enumerate tables in query and put them in right order in join sequence. It should be some kind of topological sort of this objects, or maybe I have to create some kind of tree...
I'm not going to apply something like query optimization algorithm, I just want to enumerate tables and create syntactically right Select query with nested joins.

I'll really appreciate every idea and help information.
Thank you in advance.

Bulent Karaahmed