Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: OO concepts and relational databases

by Solo (Deacon)
on Aug 03, 2004 at 19:51 UTC ( #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.


Comment on Re^3: OO concepts and relational databases
Select or Download Code
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
Node Status?
node history
Node Type: note [id://379809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-12-28 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls