Last active
May 10, 2016 16:22
-
-
Save satish3485/5ce3fecca9069c7f5ef239601aa8fdc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| = REPLACEME: TITLE OF YOUR GRAPHGIST | |
| :neo4j-version: 2.3.0 | |
| :author: SATISH KUMAR | |
| = Homework Assignement: Create a small Graph Use Case Model with Neo4j and Cypher | |
| == Domain and Data | |
| Take a domain that you are really interested in, be it politics, beer, music, arts, cooking, sports, travel, software, organizations. | |
| Draw a model of the domain on a whiteboard or digitally, add a few example entities (nodes) you know and their relationships. | |
| Think about at least 3 questions you want to answer using this _connected_ data. | |
| Remember to add all the information you need to answer those questions. | |
| You should end up with *at least 15 nodes and 20 relationships*. | |
| == GraphGist Format | |
| Now go to http://portal.graphgist.org/about and learn about the GraphGist documentation format (which is basically AsciiDoc a text-markup language with a few embellishments). | |
| You can either start from the template that is provided there or a blank plain text file. | |
| You can also explore the other GraphGists on the portal for further inspiration. | |
| == Setup | |
| Add a snappy *title* for your demo and *some prose* that describes the domain and the types of its entities and their relationships. | |
| Now *add an image* link, e.g. to the drawing you created earlier. | |
| Now you can start creating your domain with Cypher, Neo4j's query language in a *Setup* section. | |
| Follow the syntax example in the template or on the portal page. | |
| image::http://cdn.yourarticlelibrary.com/wp-content/uploads/2013/12/415-1.jpg[width=200] | |
| == Setup | |
| //// | |
| A Cypher query to setup the database | |
| Please use a small sample of your domain, at most 150 nodes and 200 relationships are enough for the pedagocial example. | |
| You can link to the setup of a larger dataset or LOAD CSV queries in a second file of your GitHub Gist at the end. | |
| In your setup query you can also use LOAD CSV loading CSV files from your GitHub Gist, like here: https://gist.github.com/jexp/f78df7b232d0faa171ff | |
| //// | |
| //setup | |
| //hide | |
| [source,cypher] | |
| ---- | |
| CREATE | |
| (a:Person {name: 'Mahendra Singh Dhoni'}), | |
| (b:Woman {name: 'Virat Kohli'}), | |
| (c:Child {name: 'Ajinkya Rahane'}), | |
| (d:Bigger {name: 'Shikhar Dhawan'}), | |
| (e:Smallest {name: 'Rohit Sharma'}), | |
| (f:Person {name: 'Stuart Binny'}), | |
| (g:Person {name: 'Suresh Raina'}), | |
| (h:Person {name: 'Ravindra Jadeja'}), | |
| (i:Person {name: 'Ambati Rayudu'}), | |
| (j:Person {name: 'Axar Patel'}), | |
| (k:Person {name: 'Ravichandran Ashwin'}), | |
| (l:Person {name: 'Bhuvneshwar Kumar'}), | |
| (m:Person {name: 'Mohammed Shami'}), | |
| (n:Person {name: 'Umesh Yadav'}), | |
| (o:Person {name: 'Ishant Sharma'}), | |
| (p:Dog {name: 'Tommy'}), | |
| (a)-[:HUSBAND]->(b), | |
| (a)-[:SON]->(e), | |
| (b)-[:SON]->(e), | |
| (b)-[:FRIENDS_WITH]->(c), | |
| (a)-[:FRIENDS_WITH]->(d), | |
| (e)-[:DAUGHTER]->(f), | |
| (e)-[:SON]->(g), | |
| (h)-[:WIFE]->(e), | |
| (h)-[:DAUGHTER]->(f), | |
| (h)-[:SON]->(g), | |
| (b)-[:AUNT]->(i), | |
| (a)-[:UNCLE]->(i), | |
| (j)-[:GRAND_FATHER]->(f), | |
| (k)-[:GRAND_MOTHER]->(g), | |
| (l)-[:SISTER_IN_LAW]->(k), | |
| (m)-[:BROTHER_IN_LAW]->(l), | |
| (n)-[:GIRLFRIEND]->(k), | |
| (o)-[:TEACHER]->(l), | |
| (a)-[:LOVES]->(p), | |
| (b)-[:LOVES]->(p), | |
| (c)-[:LOVES]->(p), | |
| (d)-[:LOVES]->(p), | |
| (f)-[:LOVES]->(p), | |
| (g)-[:LOVES]->(p), | |
| (h)-[:LOVES]->(p), | |
| (i)-[:LOVES]->(p), | |
| (j)-[:LOVES]->(p), | |
| (k)-[:LOVES]->(p), | |
| (h)-[:SON]->(g), | |
| (i)-[:PROF]->(o), | |
| (e)-[:BROTHER]->(a), | |
| (j)-[:FINANCE_ADVICER]->(f) | |
| ---- | |
| //graph | |
| == Name all the people who loves dogs | |
| // REMOVEME: Describe what this use-case is solving and how the query represents that | |
| // REMOVEME: A Cypher query with tabular output, returning scalar values | |
| // Name all the people who loves dogs | |
| [source,cypher] | |
| ---- | |
| //MATCH (a:Person {name: 'Mahendra Singh Dhoni'})-[:HUSBAND]-(:Woman)-[:LOVES]-(name:Dog) | |
| MATCH (a:Person)-[:LOVES]-(name:Dog) | |
| RETURN a.name as name,count(*) as count | |
| ---- | |
| //table | |
| == REPLACEME: SECOND USE-CASE TITLE | |
| // REMOVEME: Describe what this use-case is solving and how the query represents that | |
| // REMOVEME: A Cypher query to with graph output | |
| [source,cypher] | |
| ---- | |
| MATCH path=(a:Person {name: 'Bhuvneshwar Kumar'})-[:SISTER_IN_LAW]-(:Person)-[:GRAND_MOTHER]-(fof:Person) | |
| RETURN path, a, fof | |
| ---- | |
| //graph_result | |
| Render the results either as `//table` *or* `//graph_result`. | |
| == Submission & Grading | |
| While you're working and when you are done, you can use the "Preview" functionality of the GraphGist portal to render your document in your browser. | |
| Go to http://portal.graphgist.org/submit_graphgist add the public URL of your file, your title and click `Preview`. | |
| When done, either hand in the preview link or submit your link to the portal and share the resulting link with your lecturer. | |
| *The grading will be on completeness, correct usage of Cypher, good prose and educational quality of your queries (i.e. at least 2 of the 3 should use relationships or paths).* | |
| == Resources | |
| * http://neo4j.com/graphacademy/online-course-getting-started/[Online Course] | |
| * http://neo4j.com/developer/cypher[Cypher Information on the Developer Pages] | |
| * http://neo4j.com/docs/developer-manual/current/#cypher-getting-started[Cypher in the Neo4j Manual] | |
| * http://neo4j.com/docs/cypher-refcard/current/[Cypher Refcard] | |
| * http://portal.graphgist.org/about[GraphGist Howto] | |
| * https://gist.github.com/jexp/a56f7e7587ce5ed97561[Template] | |
| Created by {author} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment