I was asked to do some kind of reporting (registration) service. An employee locally installed a web application (just some kind of dynamic website written in PHP) in many companies. This web application is a kind of survey. All data is stored in a local database, but now the requirement is that this data (the result of the survey) should also be sent to the central server after each form of sending.
There are four types of surveys. They organized it in such a way that there are many projects, and each project can have only one overview of each type (STI here?), And Survey belongs to one project. Each survey will receive a report from the local application, so it will have many reports. The Rails 3 application that logs these reports must somehow mimic this logic. First question: does this AR structure really make sense to you?
Project-1--------1-Survey-1-------*-Report Project has_one :survey has_many :reports, :through => :survey Survey belongs_to :project has_many :reports Report belongs_to :survey
The second question concerns the availability of several tables for one AR model. If all the data is stored in the reports table, the table will become very fast, and efficiently requesting reports related to a particular survey can be a problem after a while. Maybe it would be better to have separate tables for each survey? Like reports_<survey_id> . Is it possible?
In addition, I somehow have to use MySQL, but if there is another, much better solution for this, I could try to skip it.
If you are still here, thank you for that :)
activerecord ruby-on-rails-3
Ernest
source share