Created
May 25, 2016 12:16
-
-
Save rdmpage/2a6e3bc1fb06177d1c28d3a136712a07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== 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