Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Data Modeling Training San Francisco
MERGE (acme:company{name:'acme'})
// Skills
MERGE (java:skill{name:'java'})
MERGE (sql:skill{name:'sql'})
MERGE (neo4j:skill{name:'neo4j'})
MERGE (jquery:skill{name:'jquery'})
MERGE (jasperreports:skill{name:'jasperreports'})
MERGE (oracle:skill{name:'oracle'})
MERGE (c:skill{name:'c'})
MERGE (mssql:skill{name:'mssql'})
MERGE (d3:skill {name:'d3.js'})
MERGE (dc:skill {name:'dc.js'})
MERGE (data:skill {name:'data visualization'})
MERGE (spring:skill{name:'spring'})
MERGE (agile:skill{name:'agile'})
MERGE (perl:skill{name:'perl'})
MERGE (vb:skill{name:'vb'})
MERGE (postgres:skill{name:'postgres'})
MERGE (shelley:person{name:'shelley'})
CREATE (shelley)-[:WORKS_FOR]->(acme),
(shelley)-[:HAS_SKILL]->(java),
(shelley)-[:HAS_SKILL]->(oracle),
(shelley)-[:HAS_SKILL]->(sql),
(shelley)-[:HAS_SKILL]->(spring),
(shelley)-[:HAS_SKILL]->(agile),
(shelley)-[:HAS_SKILL]->(perl),
(shelley)-[:HAS_SKILL]->(vb),
(shelley)-[:HAS_SKILL]->(postgres)
// People
MERGE (roger:person{name:'Roger'})
MERGE (sherry:person{name:'sherry'})
MERGE (liz:person {name:'Liz'})
MERGE (king:person {name:"king"})
// People -> Company and Skill relationships
CREATE (roger)-[:WORKS_FOR]->(acme),
(roger)-[:HAS_SKILL]->(java),
(roger)-[:HAS_SKILL]->(sql),
(roger)-[:HAS_SKILL]->(jquery),
(roger)-[:HAS_SKILL]->(jasperreports),
(sherry)-[:WORKS_FOR]->(acme),
(sherry)-[:HAS_SKILL]->(neo4j),
(sherry)-[:HAS_SKILL]->(c),
(sherry)-[:HAS_SKILL]->(oracle),
(sherry)-[:HAS_SKILL]->(mssql),
(liz)-[:WORKS_FOR]->(acme),
(liz)-[:HAS_SKILL]->(neo4j),
(liz)-[:HAS_SKILL]->(sql),
(liz)-[:HAS_SKILL]->(d3),
(liz)-[:HAS_SKILL]->(dc),
(liz)-[:HAS_SKILL]->(data),
(king)-[:WORKS_FOR]->(acme)
merge (imran:person {name: 'iansari'})
merge (imran) - [:WORKS_FOR] -> (acme)
merge (imran) - [:HAS_SKILL] -> (neo4j)
merge (imran) - [:HAS_SKILL] -> (ruby)
merge (imran) - [:HAS_SKILL] -> (java)
MERGE (alberto:person{name:'alberto'})
MERGE (acme)<-[:WORKS_FOR]-(alberto)
MERGE (alberto)-[r1:HAS_SKILL]->(java)
MERGE (alberto)-[r2:HAS_SKILL]->(android)
MERGE (alberto)-[r3:HAS_SKILL]->(neo4j)
MERGE (edwin:person{name:"edwin"})
MERGE (edwin)-[:WORKS_FOR]->(acme)
MERGE (storage:skill{name:"storage"})
MERGE (unix:skill{name:"unix"})
MERGE (mysql:skill{name:"mysql"})
MERGE (edwin)-[:HAS_SKILL]->(c)
MERGE (edwin)-[:HAS_SKILL]->(php)
MERGE (edwin)-[:HAS_SKILL]->(storage)
MERGE (edwin)-[:HAS_SKILL]->(unix)
MERGE (edwin)-[:HAS_SKILL]->(mysql)
MERGE (edwin)-[:HAS_SKILL]->(oracle)
MERGE (edwin)-[:HAS_SKILL]->(jquery)
MERGE (edwin)-[:HAS_SKILL]->(neo4j)
MERGE (fede:person{name:'Fede'})
merge (jimmy:person {name:'jimmy'})
MERGE (aj:person{name:'Anthony'})
MERGE (me:person{name:"michael"})
merge (mongodb:skill {name:'mongodb'})
MERGE (python:skill{name:"python"})
MERGE (math:skill{name:"math"})
MERGE (ep:skill{name:"entrepreneurship"})
MERGE (nodejs:skill{name:'node.js'})
MERGE (angular:skill{name:'angular'})
MERGE (fede)-[:WORKS_FOR]->(acme)
MERGE (fede)-[:HAS_SKILL]->(php)
MERGE (fede)-[:HAS_SKILL]->(neo4j)
MERGE (fede)-[:HAS_SKILL]->(javascript)
MERGE (fede)-[:HAS_SKILL]->(mysql)
MERGE (fede)-[:HAS_SKILL]->(ep)
merge (jimmy)-[:WORKS_FOR]->(acme)
merge (jimmy)-[:HAS_SKILL]->(neo4j)
merge (jimmy)-[:HAS_SKILL]->(ruby)
merge (jimmy)-[:HAS_SKILL]->(mongodb)
merge (jimmy)-[:HAS_SKILL]->(sql)
merge (jimmy)-[:HAS_SKILL]->(javascript)
merge (jimmy)-[:HAS_SKILL]->(perl)
merge (jimmy)-[:HAS_SKILL]->(c)
MERGE aj-[:WORKS_FOR]->(acme)
MERGE aj-[:HAS_SKILL]->(c)
MERGE aj-[:HAS_SKILL]->(javascript)
MERGE aj-[:HAS_SKILL]->(mongodb)
MERGE aj-[:HAS_SKILL]->(nodejs)
MERGE aj-[:HAS_SKILL]->(angular)
MERGE aj-[:HAS_SKILL]->(neo4j)
MERGE me-[:WORKS_FOR]->(acme)
MERGE me-[:HAS_SKILL]->(c)
MERGE me-[:HAS_SKILL]->(javascript)
MERGE me-[:HAS_SKILL]->(neo4j)
MERGE me-[:HAS_SKILL]->(math)
MERGE me-[:HAS_SKILL]->(python)
MERGE me-[:HAS_SKILL]->(ep)
WITH king, ['neo4j', 'python', 'objective-c', 'c', 'javascript', 'java', 'coffeescript'] as skills
FOREACH (skill_name IN skills |
MERGE (s:skill {name:skill_name})
MERGE (king)-[:HAS_SKILL]->(s)
)
MATCH (roger:person { name: 'king' })-[:HAS_SKILL]->(skill),
(skill)<-[:HAS_SKILL]-(people)
WITH roger.name as person1, collect(DISTINCT skill.name) as skills, people.name as person2
RETURN person1, person2, skills
ORDER BY length(skills) DESC
MATCH (n1:node { n.id = "1234" })
MATCH (n0)-[r1]->(n1)-[r2]->(n2)
DELETE r1, n1, r2
MERGE (n0)-[:NEXT]->(n2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment