Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Just to refocus on the OP, the question was, (given the example 'one-off' solution that BrowserUk illustrated for this specific example, and considering the similarly-coded 'one-off' solutions by the OP in the past) where does there exist a "general purpose" mechanism to further abstract the process of doing this kind of transformation, such that there is no need to modify the 'one-off' code every time someone wants a different 'pivot' of the data structure.

The question is now mostly academic, since the humble aspirant has gone on to code a solution himself, absent a preexisting and obvious choice out there.

It is called 'vpath_pivot', named after the 'pivot table' feature found in spreadsheet software. It generates arbitrarily-nested tree structures using perl data variables, constructed from queries like:

### 1: provides same output as BrowserUk example TREE_SELECT genre,title,fname,lname FROM tvshow WITH_LEVELS ('genre','title' ) WITH_RECORD ( 'lname','fname' ) ### 2: a different 'pivot' of the same data TREE_SELECT title,genre,fname,lname FROM tvshow WITH_LEVELS ('title','genre','lname' ) WITH_RECORD ( 'fname' ) WHERE genre != 'gameshow' ### 3: another tree 'pivot' (more compact) TREE_SELECT title,fname,lname FROM tvshow WITH_LEVELS ('title' ) WITH_RECORD ( 'fname','lname' )

NOTE: the above is not SQL, it just looks similar for readability.

NOTE: the main approach here is to give the user the ability to 'slice and dice' the 'flat' data into different 'tree structures' all within a simple syntax (i.e., no need to re-edit the perl code).

tyvm for the replies
=oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV

In reply to Re^3: tree-oriented query against table-oriented data by dimar
in thread tree-oriented query against table-oriented data by dimar

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-28 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found