I don't know much about Class::DBI, but I have spent some time over the OO <-> relational DBMS questions.
The three classical solutions for subclassing are:
- One common table for all subclasses, containing all attributes that appear in any of the subclasses;
- One table for the common attributes and one for each class. The class-table contains the class-specific attributes, plus a pointer-field to the record in the common class (this is my favourite);
- One table for each class, each table having columns for both common and class-specific attributes.
In the first and second case, a query over the common attributes will probably map to a single QUERY statement.
In the third case, you have to repeat the query for all subclasses.
In case 1/2, you will probably have to deal with casting issues, since after getting the common attributes you should determine what class they belong to and retrieve the remaining attributes. This can be transparent and often avoid one more query if the mapping layer implements lazy attributes. In case 3, you would not face this problem, because each query would only deal with one class.
Best regards
Antonio Bellezza
N.B. Throughout the post, "probably" is short for "in most conditions, depending on implementation of the mapping layer".
The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.