Brian Glass wrote:
> A car has a color. There are a list of colors in the status_code table
> all with the status_type column set to color. A car has_a color. A
> person can be either a driver or a passenger. There are a list of person
> roles in the status_code table all with the status_type column set to
> person_role. A person has_a person_role.
I've seen this kind of table design used before, and it was always
regretted later. Having one big lookup table for everything might sound
like a good idea at first, but it generally makes your life more
complicated than simply using separate tables and it hurts the
performance of your database.
If you really want to pursue it, you can create custom methods to map to
the table:
My::Car->has_a(color => 'My::StatusCode');
sub available_colors {
return My::StatusCode->search(status_type => 'color');
}
You would probably want to add a constraint to limit the acceptable
values set in color. See "contrain_column" in the Class::DBI docs.
- Perrin
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT