Cadasta / cadasta-docs

Documentation for Cadasta legacy platform
GNU Affero General Public License v3.0
3 stars 2 forks source link

Import Addition :: Importing data with one to many relationships #59

Open SteadyCadence opened 7 years ago

SteadyCadence commented 7 years ago

For importing, many to one relationships it is recommended to use the xlsx format.

File with many locations to one party: test_one_to_many.xlsx

You need to add your locations to the locations tab, parties to the parties tab and then define the join between them in the relationships tab. If the entities don't have ids you'll need to assign them. IDs get dropped anyway on import. They are just used for the join during the import

dpalomino commented 7 years ago

@bethschechter, maybe we should document this in the online documentation.

bethschechter commented 7 years ago

@dpalomino yes! Happy to do it.

I do have a question, maybe for @SteadyCadence: Where would a spreadsheet like this come from? Would someone have to create it themselves? Is it an export of an existing project? I want to make sure we document how to get to a spreadsheet like this one as well as how to use it.

If it's not an easy answer to write, lmk when is a good time to pick your brain.

Thanks! Beth

dpalomino commented 7 years ago

Hey @bethschechter

Picking up this, as I know @SteadyCadence is REALLY busy.

So typically importing data via xlsx files is used for "cloning" projects, so moving data from one Cadasta project to another Cadasta project, because it has to follow the "Cadasta format" used when downloading a project. That's having the "locations", "parties" and "relationships" tabs.

If you take a look to one of them, for instance this simple sample file: demo-project-1.xlsx

You see that there is an "id" column in "locations" and "parties" tab. This id links locations with parties, and the mapping table is in the "relationships" tab (party_id, spatial_unit_id columns).

One workaround to import data not having a 1-1 relationship between locations and parties is to make up the ids (should be unique in the file) for both parties and locations, and then do the corresponding mapping table.

Probably this is a bit complicated for most of our users, maybe we can just added as an "Advanced Import Tip", or something like that.

If you think a live demonstration would help ping me and we can do a quick test.