Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: OO concepts and relational databases

by Solo (Deacon)
on Aug 03, 2004 at 19:51 UTC ( [id://379809]=note: print w/replies, xml ) Need Help??


in reply to Re^2: OO concepts and relational databases
in thread OO concepts and relational databases

That said, you can approximate an IS-A relationship between tables, but it's cumbersome and prone to mistakes.

This statement seems contradictory to your idea about a separate table for optional attributes. That is merely a further generalization of the approximate IS-A relationship, and is equally cumbersome and prone to mistakes, if not moreso.

How is it more cumbersome to have the tables

Animal .id .name .type Mammal .animal_id .hair_color Reptile .animal_id .num_of_limbs

Than to have the tables you are proposing?

Animal .id .name .type AnimalAttribute .animal_id .attribute_id .value Attribute .id .name

--Solo
--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^4: OO concepts and relational databases
by dragonchild (Archbishop) on Aug 03, 2004 at 20:08 UTC
    Those solve different problems. The first solves the IS-A problem and is the cumbersome and error-prone solution I was referring to. The second solves the problem of a large number of optional attributes and is an alternative to having dozens of columns in your main table, most of which are NULL for any given row.

    There have been situations where I will use both solutions for different issues in my design. In fact, you can use both solutions for the same tables, if you need it.

    And, the two solutions can be considered interchangeable, for a limited subset of IS-A problems. But, the second solution becomes very unwieldy for most IS-A problems.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-19 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found