I have a rather complex legacy db I'd like to access via ActiveRecord and I'm not sure how to model it wisely. I have a lot of tables that follow the following format: Table name: CDM_CONFIGURATION_ITEMS Primary key: CIT_OID Then extra columns for CI's in another table: Table name: CDM_CONFIGURATION_ITEMS_X Primary key: XCIT_CIT_OID <-- links to the CIT_OID above And not to be to simple, a bunch of more extra columns in tables such as: Table name: CDM_CONFIGURATION_ITEMS_X_SD_1 Primary key: XCIT1_CIT_OID <-- links to the CIT_OID in the top level ... Table name: CDM_CONFIGURATIO_ITEMS_X_SD_10 Primary key: XCIT10_CIT_OID Now if I make a normal model I'd access the extra columns like: ci.ci_x_1.xcit1_maximum_installations which doesn't seem like fun at all, since I'd always have to look up which table each column is in from a list. There are a lot of columns per table and listing them all for send() in the main model doesn't look like an elegant solution either and would require a lot of handiwork to collect all the column names. I guess iterating through all the extra models and asking if they have the method requested via method_missing would cause AR to fetch the row in question from every table? Of course the column names could be cached... Getting complicated. Ideas?
on 2007-04-23 14:44