Hello Gurus! I have a problem with legacy database-schema and I would like to get some ideas and suggestions how to handle it with ActiveRecord. First the idea with database is that there can be several versions of the same data. Current data is only one row but the same data can be saved on several rows. Example: identification varchar2(10) area varchar2(30) owner varchar2(50) effective_date datetime termination_date datetime The SQL used to get current data is: select * from example_table e where e.identification='123456' and termination_date is null and effective_date=(select max (effective_data) from example_data where identification='123456') What I would like to achieve is at least partially RESTful wrapper around the datamodel. There are dozens of tables like the example and there aren't any integrity constraints defined (no foreign keys used). Responsibility of the data-integrity is pushed to the application logic. Yes, if it were up to me the legacy schema would be modified and made more sensible. Unfortunately I cannot affect since my application isn't the only one using it. So I'm stuck with situation where I just have to live with it. I probably build couple of prototypes for managers with Sinatra before making a full-blown rails-app. What would be the best way to wrap this kind of datamodel under ActiveRecord-umbrella? Loads of custom SQL at least I think.
on 2009-02-05 20:02