(I'm not sure what to call this node, so someone please retitle this, as necessary.)

I'm writing Yet Another SQL Generator (YASG) and the basic concept is as follows:

  1. There are some number of basic queries (reports)
  2. Each report can be run for any given type, aka the "runfor"
  3. Each report can be grouped by any other given type, aka the "groupby"
  4. For each type, I know the SQL needed to do that limiting action
  5. I know how to link any table X to its neighbor tables
  6. The schema is in Third Normal Form.

The runfor and groupby could be for any tables in the schema, as can the report query. I have figured out the tables needed for the runfor and the groupby. (I already know the tables from the report query.)

What module(s) would be useful to figure out what path I need to take to the schema in order to join the runfor and groupby tables to the report tables. What I'm looking for is something like "To connect tables A and D, you need to go this path: A->B->C->D".

I'm going to be caching the generated SQL when mod_perl starts up, so runtime isn't a major concern. Ideally, I'd like the shortest path, determined by number of elements in the path. (I'm not worried about table sizes or anything like that. Optimization comes later, if necessary.)

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Path computation for SQL generation by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.