Skip to content

Instantly share code, notes, and snippets.

@stardustnrust
Forked from Pimsepinnen/peoplebooksandcities
Last active August 29, 2015 14:01
Show Gist options
  • Save stardustnrust/f727dc2200d338f2dcab to your computer and use it in GitHub Desktop.
Save stardustnrust/f727dc2200d338f2dcab to your computer and use it in GitHub Desktop.
Nabokov in America
= Nabokov in America
=== “Genius is non-conformity.”
― Vladimir Nabokov,
image::http://static.guim.co.uk/sys-images/Books/Pix/pictures/2009/7/8/1247059161848/Vladimir-Nabokov-001.jpg[]
== Modeling the Graph
image::http://www.library.vanderbilt.edu/webimages/LNO/datamodel.JPG[]
=== OUR DATASET
[source, cypher]
----
CREATE
//People
(nabokov:Person{name:'Nabokov',persname:'Vladimir Nabokov'}),
(hermanmelville:Person{name:'Herman Melville'}),
(stanleykubrick:Person{name:'Stanley Kubrick'}),
(thomaspynchon: Person {name:'Thomas Pynchon'}),
(peteryarrow: Person {name: 'Peter Yarrow'}),
(ruth: Person {name: 'Ruth Bader Ginsburg'}),
(farina: Person {name: 'Richard Farina'}),
(mccarthy: Person {name: 'Mary Mcarthy'}) ,
(boyle: Person {name: 'T Coraghessan Boyle'}) ,
(parker: Person {name: 'Dorothy Parker'}) ,
//Works
(lolita:Works:Book{name:'Lolita'}),
(gravitysrainbow:Works:Book{title:'Gravitys Rainbow'}),
(mobydick:Works:Book{title:'Moby Dick'}),
(lolitafilm:Works:Film{title:'Lolita Film'}),
(dragon:Works:Song{title:'Puff the Magic Dragon'}),
(been:Works:Book{title:'Been Down So Long it Looks Like Up To Me'}),
//Quotes
(palefire:Works:Quote{title:'Pale Fire is a Jack, a Faberge gem, a clockwork toy, a chess problem, an infernal machine, a trap to catch reviewers, a cat game, a do novel.'}),
(oevre:Works:Quote{title:'Nabokovs playfulness and the ravishing beauty of his prose are ongoing influences.'}),
(lolitabook:Works:Quote{title:'Lolita is a fine book, a distinguished book — all right then — a great book. '}),
//Relationships
(peteryarrow)-[:WAS_STUDENT]->(nabokov),
(farina)-[:WAS_STUDENT]->(nabokov),
(ruth)-[:WAS_STUDENT]->(nabokov),
(thomaspynchon)-[:WAS_STUDENT]->(nabokov),
(nabokov)-[:TAUGHT]->(peteryarrow),
(nabokov)-[:TAUGHT]->(thomaspynchon),
(nabokov)-[:INFLUENCED_BY]->(mobydick),
(thomaspynchon)-[:INFLUENCED_BY]->(lolita),
(stanleykubrick)-[:WROTE]->(lolitafilm),
(hermanmelville)-[:WROTE]->(mobydick),
(nabokov)-[:WROTE]->(lolita),
(thomaspynchon)-[:WROTE]->(gravitysrainbow),
(peteryarrow)-[:WROTE]->(dragon),
(farina)-[:WROTE]->(been),
(mccarthy)-[:SAID]->(palefire),
(boyle)-[:SAID]->(oevre),
(parker)-[:SAID]->(lolitabook)
----
//table
//graph
=== Which person created which work?
[source, cypher]
----
MATCH (person)-[:WROTE]->(works)
RETURN person.name, works.title;
----
//table
//graph
=== Which person was influenced by which work?
[source, cypher]
----
MATCH (person)-[:INFLUENCED_BY]->(works)
RETURN person.name, works.title;
----
//table
//graph
=== Which person was a student of Nabokov?
[source, cypher]
----
MATCH (person)-[:WAS_STUDENT]->(nabokov)
RETURN person.name;
----
//table
//graph
=== Who said what about a Nabokov Book?
[source, cypher]
----
MATCH (person)-[:SAID]->(works)
RETURN person.name, works.title;
----
//table
//graph
=== What did students of Nabokov write?
[source, cypher]
----
MATCH (n {persname:'Vladimir Nabokov'})<-[:WAS_STUDENT]-(students)
WITH students
MATCH (students)-[r:WROTE]->(works)
RETURN students.name AS Students, works.title AS Titles;
----
//table
//graph
=== By all means place the "how" above the "what" but do not let it be confused with the "so what.”
― Vladimir Nabokov, Strong Opinions
image::http://www.nytimes.com/books/99/04/25/specials/nabokov.4.jpg[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment