Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
How do I link those abstractions together with has-a relationships? (RDBMSes don't have is-a relationships.)
That's what boolean and number types are useful for.

Simple example, a boolean type for male on a person. male = false, means it's a woman. It IS an is-a type realtionship. I could create a male and female abstract type with hard-coded methods called gender(), but that's a little inefficient.

Further more, you can do the same with numbers. For instance, when you have an address type table, if you normalized the country out to another table and used ids, you have an isa type relationship that would be accomplished by creating hundreds of tag classes, package America, package Canada, package Barbados, package St Vincent. But that's just OOP hell. It's a little outlandish and a poorer representation than saying an address has-a country than an address is of this country's type.

The latter example isn't the BEST one. Lets give another. Take books. They are escentially all of the same ilk. Some are text, some are novel, some are reference. I doubt someone is going to create a reference, text and novel supertype when a field describing it is more direct.

Classes are not tables and attributes are not columns In other words, there is (almost) never a 1-1 relationship between them.
Never use never. Someone will have an example where for them, a class->table relationship works well for them. It may not be complex, but it doesn't prevent it from existing. :)

Bart: God, Schmod. I want my monkey-man.

In reply to Re: OO concepts and relational databases by exussum0
in thread OO concepts and relational databases by dragonchild

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (6)
    As of 2021-01-21 23:33 GMT
    Find Nodes?
      Voting Booth?