Best way to create / import many-to-many relationships?

Hi all,

I was wondering what the recommended way to create relationships is, particularly many-to-many.

I’ve done it using Link with one-to-one and one-to-many relationships within a single csv or between csvs, where I’d specify source ids and target ids in the CSV.

However, I’m not sure what the best way to prespecify many-to-many relationships is. Theoretically, it works if you have multiple target id columns and you add in multiple relationships between the source column and the target columns in Link. This doesn’t feel like the best way, though.

• I suppose you can manually add in relationships within GraphXR using Add Edge, but if I’m certain about the relationship then I might as well put it in the source CSV.
• I’m familiar with the CSV mapping tool, but either I’m not using it right or it’s not ideal for my purposes (I can’t work out whether it works if you haven’t already put source and target ids in the original csv)
• Maybe a separate CSV with just the relationships and no nodes data? But I don’t know how to directly load a CSV into Relationship rather than Category
• I think you can do this quickly using a Cypher query, but for my purposes it’d be ideal to not have to use any Cypher.

In summary, what’s best practice for creating many-to-many relationships between multiple CSVs without using Cypher?

Thank you!

Maurits

Hi Maurits,

It sounds like you might be missing the “As Key” checkbox in the CSV mapping editor:

This will walk you through the whole process:

1 Like

Hi Sony,

Thank you very much for your reply. And what if I want to put in the same relationship multiple times, going from one node to multiple others? For example, let’s say a character could be loyal to two houses. Would you have a csv that has, for instance, Jon Snow as the character, with columns Born to House (= Targaryen), Loyal to House (= Stark), and Loyal to House_2 (= Targaryen) and, in the mapping editor (or in Link) map both to the same relationship, e.g. ‘is_loyal_to’?

Apologies if I’m missing something - I’ve been doing it with multiple columns, which works fine, but I’m wondering.

Thank you,

Maurits

Hi @vestbroyek, another way in which you can map a category of characters to multiple houses in your example is by using the Extract transform. Take this sheet, for example, where I listed multiple houses under the category House. Under Extract, you can mark House “as key” property to be “split” on the comma.

Screen Shot 2021-06-30 at 10.18.49 AM

Is this along the lines of what you are trying to do?

1 Like

Hi Alex,

Yes, this is great. Thank you (and Sony) very much for your answer!

Maurits

PS Would have been interesting if Arya had also been a Targaryen!

That would have been very interesting, indeed!