Skip to content

Instantly share code, notes, and snippets.

@shivswami
shivswami / case.adoc
Created January 17, 2014 09:00 — forked from nawroth/case.adoc

The case for CASE

This is how you might model Premier League managers tenures at different clubs in Neo4j:

managers tiff

The date modeling is based on an approach described in more detail in Return partly shared path ranges.

= Untying the Graph Database Import Knot =
This Graphgist accompanies http://blog.bruggen.com/2013/12/untying-graph-database-import-knot.html[my blogpost of December 6th, 2013] which tries to explain the different types of questions that people should be asking themselves when thinking about importing data into http://www.neo4j.org[neo4j], and the tools that can contribute to finding the most optimal import strategy for your specific use case.
//setup
//hide
[source,cypher]
----
create (n1:Tool {id:'1',name:'Spreadsheets'}),
(n2:Tool {id:'2',name:'Cypher Statements'}),
= People, books and cities
=== “Those who find ugly meanings in beautiful things are corrupt without being charming. This is a fault. Those who find beautiful meanings in beautiful things are the cultivated. For these there is hope. They are the elect to whom beautiful things mean only Beauty. There is no such thing as a moral or an immoral book. Books are well written, or badly written. That is all.”
― Oscar Wilde, The Picture of Dorian Gray
image::http://i.imgur.com/425PvXE.jpg[]
== Modeling the Graph
Let's take a look at the domain model:
#!/usr/bin/env python
# encoding: utf-8
'''
linkedin-query.py
Created by Thomas Cabrol on 2012-12-03.
Customised by Rik Van Bruggen
Customised by Torbjorn Sjogren
Copyright (c) 2012 dataiku. All rights reserved.
create ({id:'1',name:'DeepPAX',type:'ShopArticle'});
create ({id:'112996',name:'Screw',type:'Component'});
create ({id:'124593',name:'Nail',type:'Component'});
create ({id:'113434',name:'ScrewLock',type:'Component'});
create ({id:'101375',name:'WoodStick',type:'Component'});
create ({id:'100402',name:'Screw',type:'Component'});
create ({id:'100644',name:'Screw',type:'Component'});
create ({id:'100347',name:'Screw',type:'Component'});
create ({id:'103693',name:'LockPlate',type:'Component'});
create ({id:'123773',name:'CornerCover',type:'Component'});
= IKEA GraphGist =
This gist is to complement the http://blog.bruggen.com/2013/09/ikea-wardrobes-and-graphs-perfect-fit.html[more elaborate blogpost] that I wrote about using http://neo4j.org[neo4j] to model the partlist and the assembly process of two IKEA wardrobes.
First, we will create a part of the graph using this model:
image::https://lh4.googleusercontent.com/7XxUuCjnFtDhO-JAI5Ia6tcYZkQoMfcv_1pNE0mTA2cx76vIySrBU0z0tnykAPvqsMrZZD-cca3Q7ca-ERI0f5sDsGAUCEJTIx7wt15mxKhFEXeYFrZD_vEGJQ[]
[source,cypher]
----
@shivswami
shivswami / lms-graph
Created December 19, 2013 07:16 — forked from luanne/lms-graph
= Organization Learning
Learning Management Systems (LMS) are typically deployed in large organizations to support learning processes that align with business goals. These systems tie together their employees, organizations, certifications, courses, jobs in order to supplement business strategy.
This graph gist models a slice of this ecosystem- certification paths and position dependencies on certifications.
== Domain
A certification has one or more learning paths. A learning path is an ordered sequence of items that must be completed in order to acquire the certification. A learning item can be completed by taking a course or proving work experience. A course has a delivery type- it can be web based or classroom. Work Experience specifies the number of hours one must put in to complete it.
To aquire a certification, an employee can take take any learning path and complete every item in it.
Employees hold certifications and complete courses and work experience. An employee may fill a position which require
= Business Rule / Recommendation gist =
In this simple example, we want to highlight the power of graphs to describe, discover, visualise and implement powerful business rule-based recommendations.
In the example, we will create a simple graph containing
- a +person+ ("Rik")
- a +city+ ("London")
- an +age+ ("39")
- a +child+ ("Toon")
and all the required relationships from the person to the city, to his age, and his child.

Harry Potter

harry

Welcome to the wonderful world of Harry Potter!

v0 of this graph models some of Harrys friends, enemies and their parents. Also have some pets and a few killings. The obvious relation missing is the one between Harry Potter and Voldemort- it took us 7 books to figure that one out, so you’ll have to wait till I add more data :-)

The model