php - Struggling with Cypher & CREATE UNIQUE -


i reading soccer match data text file , want create matches , referee nodes. way want logic work create match node , referee name , create referee node if referee not exist else link existing referee match. presently not have root node , not sure if should create 1 (very new graph modeling).

i have following query in think close not there.

$match= $client->makenode(); $match->setproperty('label', "match: ".$feed['match_number'])       ->setproperty('type', "match")->save(); 

//now match node created lets see if current referee in feed exists already

$querystring = "start match=node({nodeid}) ".   <----- need @ cases????? "create unique (referee{label:{name}, type:'referee'})-[:refereed{ label:'refereed' }]->(match)"."return referee";  $query = new neo4j\cypher\query($client, $querystring, array('nodeid' => $match->getid(),'name' => $feed['referee_name'])); $result = $query->getresultset(); 

can please assist?

one of possible models @ moment seem satisfy queries you've posted:

(team)-[:plays]->(match)  (match)-[:has_referee]->(referee)  (match)-[:played_in]->(city) 

the plays relation have property indicate if team home team. have property on plays relation indicate whether team won or not. or if winning big part of you're looking for, can create relation such (team)-[:won]->(match) (though need think how model draws. absence of won relation on either of 2 teams match indicate draw maybe).

  1. all matches particular referee: start @ referee, traverse through match cities. might index unique property of referee able him quickly

  2. all matches referee worked , home team won: start @ referee, find matches, filter on won relation/property , home team property

  3. all referees have highest count of wins home team: same above, start @ referees

  4. most active referees city: start @ city, find matches , referees

you might move things around bit depending on more questions want answer (especially home team properties, win/lose relations or properties etc.)

and don't think need root node @ all. can index matches/cities/referees etc if want find of them


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -