Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: OO concepts and relational databasesby exussum0 (Vicar) |
on Aug 03, 2004 at 11:02 UTC ( [id://379578]=note: 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 Section
Meditations
|
|