Personally, I would write a simple generic ORM layer and create aliases to the ORM layer.

The originial ORM layer would be a hook to the table columns and rows. However, a badly designed and implemented database can make deciphering those Table and column names a headache. So you write aliases that make more sense, from a programming stand-point, instead of hoping people will know the database schema.

Example, you have a table that looks like this,

Table: Agent

Columns
name_part_1 - a person's first name
name_part_2 - a person's last name
name_part_3 - a person's middle name

# Standard ORB print "First Name: " . $agent->name_part_1 . "\n"; print "Last Name: " . $agent->name_part_2 . "\n"; print "Middle Name: " . $agent->name_part_3 . "\n"; sub get_first_name { my $self = shift; return $self->name_part_1;} sub get_last_name { my $self = shift; return $self->name_part_2;} sub get_middle_name { my $self = shift; return $self->name_part_3;} # Using the Alias Layer print "First Name: " . $agent->get_first_name . "\n"; print "Last Name: " . $agent->get_last_name . "\n"; print "Middle Name: " . $agent->get_middle_name . "\n";

While an alias layer is not as good a refactoring, it could make your database appear to be refactored.


In reply to Re: Creating a model of a bad database by Herkum
in thread Creating a model of a bad database by Ovid

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.