Skip to content

Instantly share code, notes, and snippets.

@eric-taix
Last active December 30, 2015 21:49
Show Gist options
  • Save eric-taix/7889984 to your computer and use it in GitHub Desktop.
Save eric-taix/7889984 to your computer and use it in GitHub Desktop.
//hide
//setup
[source,cypher]
----
// League nodes
CREATE (fsgt:League{name:'FSGT 34'})
CREATE (saison14:Season{name:'Season 2013-2014', year:'2014'})
CREATE (saison13:Season{name:'Season 2012-2013', year:'2013'})
CREATE (saison12:Season{name:'Season 2011-2012', year:'2012'})
CREATE (fsgt-[:CURRENT_SEASON]->saison14),(saison14-[:PREVIOUS_SEASON]->saison13),(saison13-[:PREVIOUS_SEASON]->saison12)
// Node for competitions
CREATE(ch14:Competition{name:'Championship'})
CREATE(sc14:Competition{name:'Spring cup'})
CREATE(saison14-[:COMPETITION]->ch14),(saison14-[:COMPETITION]->sc14)
// Nodes for division
CREATE (m6:Division{name:'6x6 Male'})
CREATE (m4:Division{name:'4x4 Male'})
CREATE (i6:Division{name:'6x6 Mixed'})
CREATE (i4:Division{name:'4x4 Mixed'})
CREATE (f6:Division{name:'6x6 Female'})
CREATE (f4:Division{name:'4x4 Female'})
CREATE (ch14-[:CATEGORY]->m6),(ch14-[:CATEGORY]->m4),(ch14-[:CATEGORY]->i6),(ch14-[:CATEGORY]->i4),(ch14-[:CATEGORY]->f6),(ch14-[:CATEGORY]->f4)
CREATE (i4ex:Pool{name:'Excellence'}), (i4ho{name:'Honnor'})
CREATE (i4ex-[:POOL_OF]->i4),(i4ho-[:POOL_OF]->i4)
CREATE (m4ex:Pool{name:'Excellence'}), (m4ho{name:'Honnor'}), (m4pr{name:'Promotion'})
CREATE (m4ex-[:POOL_OF]->m4),(m4ho-[:POOL_OF]->m4),(m4pr-[:POOL_OF]->m4)
CREATE (f4ex:Pool{name:'Excellence'}), (f4ho{name:'Honnor'})
CREATE (f4ex-[:POOL_OF]->f4),(f4ho-[:POOL_OF]->f4)
// Vailhauques club
CREATE (vailhauques:Club{name:'Vailhauques'})
CREATE (vailhauques-[:REGISTERED]->saison14)
CREATE (tatouilles:Team{name:'Les tatouilles'}),(carreas:Team{name:"Les carres d\'As"}),(aspics:Team{name:'Les aspics'})
CREATE (tatouilles-[:PART_OF]->vailhauques),(carreas-[:PART_OF]->vailhauques),(aspics-[:PART_OF]->vailhauques)
CREATE (tatouilles-[:REGISTERED]->i4ex),(carreas-[:REGISTERED]->i4ex),(aspics-[:REGISTERED]->i4ho)
// Lunel club
CREATE (lunel:Club{name:'Lunel'})
CREATE (lunel-[:REGISTERED]->saison14)
CREATE (lvbdie:Team{name:'LVB/Les diesels'}),(lvbnvx:Team{name:'LVB/Les nouveaux'}),(lvbm1:Team{name:'LVB Mixte 1'})
CREATE (lvbcg1:Team{name:'LVB/COL Girl1'}),(lvbcg2:Team{name:'LVB/COL Girl2'}),(lvbcha:Team{name:'LVB/Les chabals'})
CREATE (lvbdie-[:PART_OF]->lunel),(lvbnvx-[:PART_OF]->lunel),(lvbm1-[:PART_OF]->lunel),(lvbcg1-[:PART_OF]->lunel),(lvbcg2-[:PART_OF]->lunel),(lvbcha-[:PART_OF]->lunel)
CREATE (lvbdie-[:REGISTERED]->i4ex),(lvbnvx-[:REGISTERED]->m4pr),(lvbm1-[:REGISTERED]->i4ex)
CREATE (lvbcg1-[:REGISTERED]->f4ex),(lvbcg2-[:REGISTERED]->f4ex),(lvbcha-[:REGISTERED]->m4ho)
----
//graph
=== For a club, get all divisions where at least one team is registered
[source,cypher]
----
MATCH (c:Club)<-[:PART_OF]-(t:Team)-[:REGISTERED]->(d:Division)
WHERE c.name='Vailhauques'
RETURN d.name AS Division, count(*) AS Count
----
//table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment