Mapping Db Fields to Class Attributes

Hi All, thanks who helped me yesterday …

I am currently designing my “object model” for a project management system
for software projects. One problem I have always encountered irrespective of
wehter the language is Perl, Python or Ruby is the mapping of database
fields to class attributes. For example if I do a mysql db call and load a
hash for a specific tuple, in most cases the db table names will not be in
user firendly naming format eg prj_acc_id or prj_name, it would be silly to
use these names as accesor’s in a class.

Has anyone come up with an easy yet effective way of doing this ? I was
thinking of having a corresponding hash that mapped the field name to the
attribute name

I looked at ruby’s alias option but am not sure if this is the appropriate
item to use as an alternative to hash mapping ?

Any advice would be most welcome

Graeme Matthew
Analyst Programmer
Mercer Investment Consulting
Level 29, 101 Collins Street, Melbourne, VIC, 3001, Australia
Tel - 61 3 9245 5352 Fax - 61 3 9245 5330



This e-mail and any attachments may be confidential or legally privileged.
If you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return

Thank you for your cooperation.