Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
== Handling multiple identifiers
Many objects of interest will have multiple identifiers, and each identifier may have different, complementary data associated with it.
One approach is to treat each identifier as a node, and link it to node for the corresponding object (essentially the object is treated as a bnode). We therefore refer to an object as "the object identifier by <identifier>". If we have correctly associated multiple identifiers with the same object, then we can link the two objects together.
When we have a link to create to another object, we use MERGE (id)-[]-(object) to ensure that id-object exists, then we link to it. In the example below we have a work with DOI 10.3897/phytokeys.44.7993, which cites PMID 21653447. First we create the work with DOI 10.3897/phytokeys.44.7993.
//hide
//setup
//output
[source,cypher]
----
MERGE (i:identifier {id:'doi:10.3897/phytokeys.44.7993'})<-[:IDENTIFIER]-(w:work) SET w.title='Three new species of Begonia (Begoniaceae) from Bahia, Brazil'
----
// graph
Now, we create the cited work and it's identifier
[source,cypher]
----
MERGE (cite_identifier:identifier {id:'pmid:21653447'})<-[:IDENTIFIER]-(c:work)
----
// graph
The we create the link between link between the two works by linking through their identifiers
[source,cypher]
----
MATCH (cite_identifier:identifier {id:'pmid:21653447'})<-[:IDENTIFIER]-(c:work)
MATCH (i:identifier {id:'doi:10.3897/phytokeys.44.7993'})<-[:IDENTIFIER]-(w:work)
MERGE (w)-[:CITES]->(c)
----
// graph
== Adding objects that are linked
Now, imagine that we have the article with PMID 21653447 in a queue and it's time to add it to the database.
[source,cypher]
----
MERGE (i:identifier {id:'pmid:21653447'})<-[:IDENTIFIER]-(w:work) SET w.title='Phylogenetic position and biogeography of Hillebrandia sandwicensis (Begoniaceae): a rare Hawaiian relict.'
----
// graph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.