I've been thinking about POOP a lot lately.

I'm looking to pick a RDBMS-OO mapper to use as a standard tool for (most) of my projects, and I am pretty sure that Class::DBI is the way I want to go. But one thing bothers me, how do you handle inheritance in Class::DBI (or other POOPy modules, if you have one that you really like)?

Consider a class hierarchy with three classes: Host, MailServer and WebServer.

Class: Host
Properties: ID, name, IPAddress, location, OS

Class: MailServer ISA Host
Properties: MTA, version

Class: WebServer ISA Host
Properties: httpd, version, CGI

How do I go about structuring my database for this? What if I want to have a method in Host that can return a list of all hosts (including WebServers, MailServers, and other subclasses of Host) that match some criteria? Must I keep each subclass in a separate table? Is there some obvious solution that I am missing?


TGI says moo


In reply to Inheritance, Class::DBI and POOP by TGI

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.