Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
It's already been discussed several times around here. Personally I find that building a module that fetches data from table(s) such as you propose with get_data([qw/foo bar baz/]...) works for simple situations, but will rapidly break when you start having a complex database where multiple tables need to be accessed for any particular request.

Therefore I much prefer creating logical requests that map to perl subroutines (i.e. addNewUser(), getUserInformation(), etc) that either call SQL stored procedures (my preference) or, if these aren't available, have the SQL in the subroutine.

This will also have the advantage of forcing you to structure your app a little so that you only need to create a limited number of database access methods/subroutines. This will have a huge benefit on the maintainability of the database, and on figuring out what indexes are needed (f.ex. right now one of my clients has a largeish database (about 20GB) where there is very little structure - trying to figure out what indexes are needed, and what queries are actually run is a nightmare, requiring the use of "auditing" (i.e. recodring *all* SQL that is sent to the server) and sifting through gigabytes of SQL code...)

Michael


In reply to Re: Abstracting sql by mpeppler
in thread Abstracting sql by BUU

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 examining the Monastery: (9)
As of 2024-04-23 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found