This is probably very simple, but I’m quite new to ruby and active record.
I’ve got a CSV dump of a database which I’m trying to import to a database using DataMapper. I’m having trouble understanding which type of relationships I should define in the models so that it matches what is defined CSV.
Here’s what data I’ve got from the CSV:
Stages:
id
staff_id
project_id
job_id
company_id
Projects:
id
company_id
Jobs:
id
project_id
company_id
Client:
id
Staff:
id
For example: do stages belong_to projects or is this has_many relationship?
I’m assuming client == company. Here an example for ActiveRecord
Here an example for DataMapper:
For the import you should do it in a special order:
Client,Staff, because they can exist independent of all other modelsProject, it depends only onClientJob, depends onProjectandClientStage, depends onStaff,Project,JobandClient