DS Neo4j
- Installed neo4j
- cypher-shell
- browser interface at http://127.0.0.1:7474
Tasks:
- show graph schema: 
- 10 artists: 
- artists of pop>=95 and their songs: 
MATCH (t:Track) - [:FROM_ARTIST] -> (a:Artist) WHERE (a.popularity >=95) RETURN t,a - songs with pop.>95: 
- ./., odered by popularity asc: 
MATCH (t:Track) WHERE (t.popularity>95) RETURN t.name,t.popularity as popularity ORDER BY popularity asc - artists with 80<pop<85 desc:
MATCH (a:Artist) WHERE (a.popularity>80) AND (a.popularity)<85 RETURN a.name,a.popularity ORDER BY a.popularity DESC - count artists:
MATCH (t:Track) WHERE (t.popularity>90) RETURN count(t) as number:  - show as a graph songs in “mint”:
MATCH (t:Track)-[:IN_PLAYLIST]->(n:Playlist {name:'mint'}) RETURN t -
- Which artist contributed to Migos’ song “Walk it talk it” (drake):
MATCH (n:Track {name:"Walk It Talk It"})-[:FROM_ARTIST]->(a:Artist) WHERE a.name <> "Migos" RETURN a
- Which artist contributed to Migos’ song “Walk it talk it” (drake):
-
- nodes reachable in 1-2 hops through FOLLOWS from Karolina: 
MATCH (u:User {name:"Karolina"}) -[:FOLLOWS*1..2]-(uu) RETURN u,uu(undirected edges)
- nodes reachable in 1-2 hops through FOLLOWS from Karolina: 
Advanced:
- Return all artists Daniel likes:
MATCH (u:User {name:"Daniel"})-[:LIKES]->(t:Track)-[:FROM_ARTIST]->(a:Artist) RETURN DISTINCT a(18)  - 12: top-5 artists by num of songs + average popularity of songs of artists, decr order:
MATCH (s:Track)-[:FROM_ARTIST]->(a:Artist) RETURN a,count(s) as num,avg(s.popularity) as avgpop ORDER BY num DESC LIMIT 5: - 13: songs of Ed Sheeran and someone else:
MATCH (aa:Artist)<-[:FROM_ARTIST]-(s:Track)-[:FROM_ARTIST]->(a:Artist {name:"Ed Sheeran"}) WHERE a<>aa RETURN DISTINCT s.name,aa.name:  - 14: w/ songs of the other artists:
MATCH (ss:Track)-[:FROM_ARTIST]->(aa:Artist)<-[:FROM_ARTIST]-(s:Track)-[:FROM_ARTIST]->(a:Artist {name:"Ed Sheeran"}) RETURN ss.name,aa.name,s.name (I removed the<>andDISTINCTpart.) - 15: y+m when Karolina liked the most songs:
MATCH (u:User {name:"Karolina"})-[l:LIKES]->(s:Track) RETURN l.since.month as month, l.since.year as year, count(l) as liked ORDER BY liked DESC: - 16: artist that appears the most often in playlists with songs from before 2000:
MATCH (a:Artist)<-[:FROM_ARTIST]-(s:Track)-[:IN_PLAYLIST]->(p:Playlist) WHERE s.release_date.year<2000 RETURN a.name,count(a.name) as how_often ORDER BY how_often DESC
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus