Last active
August 30, 2017 21:45
-
-
Save toraritte/977ec90705cd6f71ad81629e3b2afd68 to your computer and use it in GitHub Desktop.
Testing the creation of "identical" Neo4j and AgensGraph nodes (i.e., multiple nodes with the same attributes and labels)
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
//////////////////////////////////////////// | |
// NEO4J GRAPH SETUP | |
// | |
// http://console.neo4j.org/?id=jkwe2h | |
//////////////////////////////////////////// | |
CREATE | |
(kilgore:Person {name: 'Kilgore'}), | |
(logan:Person {name: 'Logan'}), | |
(u1:Unit {name: 'Apt 7A'}), | |
(u2:Unit {name: 'Apt 7A'}), | |
(sn1:StreetNumber {name: '27'}), | |
(sn2:StreetNumber {name: '27'}), | |
(s1:Street {name: 'Cake street'}), | |
(s2:Street {name: 'Cake street'}), | |
(c1:City {name: 'Isalie'}), | |
(c2:City {name: 'Mabase'}), | |
(cc:County {name: 'Lassen'}), | |
(kilgore)-[:OWNS]->(u2)-[:UNIT]->(sn2)-[:STREET_NUMBER]->(s2)-[:STREET]->(c2)-[:CITY]->(cc), | |
(u2)-[:ADDRESS_OF]->(kilgore), | |
(u1)-[:ADDRESS_OF]->(kilgore), | |
(u1)-[:PRIMARY_ADDRESS_OF]->(kilgore), | |
(logan)-[:RENTS]->(u1)-[:UNIT]->(sn1)-[:STREET_NUMBER]->(s1)-[:STREET]->(c1)-[:CITY]->(cc), | |
(u1)-[:ADDRESS_OF]->(logan), | |
(u1)-[:PRIMARY_ADDRESS_OF]->(logan); | |
// Query: | |
MATCH (u:Unit)-->(sn:StreetNumber)-->(s:Street)-->(:City) | |
RETURN id(u) as Unit_ID,id(sn) as StreetNumber_ID, id(s) as Street_ID; | |
//╒═════════╤═════════════════╤═══════════╕ | |
//│"Unit_ID"│"StreetNumber_ID"│"Street_ID"│ | |
//╞═════════╪═════════════════╪═══════════╡ | |
//│4 │6 │8 │ | |
//├─────────┼─────────────────┼───────────┤ | |
//│5 │7 │9 │ | |
//└─────────┴─────────────────┴───────────┘ | |
//////////////////////////////////////////// | |
// AGENSGRAPH GRAPH SETUP | |
// | |
// AgensGraph won't allow the Neo4j CREATE graph setup because | |
// (1) labels are case-insensitive and | |
// (2) edge and vertex labels must not be the same | |
// AND | |
// the query has to be slightly modified to include "empty" | |
// edge label brackets (-[]-> instead of -->) | |
//////////////////////////////////////////// | |
CREATE | |
(kilgore:Person {name: 'Kilgore'}), | |
(logan:Person {name: 'Logan'}), | |
(u1:Unit {name: 'Apt 7A'}), | |
(u2:Unit {name: 'Apt 7A'}), | |
(sn1:StreetNumber {name: '27'}), | |
(sn2:StreetNumber {name: '27'}), | |
(s1:Street {name: 'Cake street'}), | |
(s2:Street {name: 'Cake street'}), | |
(c1:City {name: 'Isalie'}), | |
(c2:City {name: 'Mabase'}), | |
(cc:County {name: 'Lassen'}), | |
(kilgore)-[:OWNS]->(u2)-[:UNIT_OF]->(sn2)-[:STREET_NUMBER]->(s2)-[:STREET_AT]->(c2)-[:CITY_IN]->(cc), | |
(u2)-[:ADDRESS_OF]->(kilgore), | |
(u1)-[:ADDRESS_OF]->(kilgore), | |
(u1)-[:PRIMARY_ADDRESS_OF]->(kilgore), | |
(logan)-[:RENTS]->(u1)-[:UNIT_OF]->(sn1)-[:STREET_NUMBER]->(s1)-[:STREET_AT]->(c1)-[:CITY_IN]->(cc), | |
(u1)-[:ADDRESS_OF]->(logan), | |
(u1)-[:PRIMARY_ADDRESS_OF]->(logan); | |
// Query: | |
MATCH (u:Unit)-[]->(sn:StreetNumber)-[]->(s:Street)-[]->(:City) | |
RETURN id(u) as Unit_ID,id(sn) as StreetNumber_ID, id(s) as Street_ID; | |
// unit_id | streetnumber_id | street_id | |
//---------+-----------------+----------- | |
// 18.2 | 19.2 | 20.2 | |
// 18.1 | 19.1 | 20.1 | |
//(2 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment