Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Homework 5

Neo4j

Hasan Kalim
MIS 4v95 Seminar Series on Information Systems

Table of Contents
Q1............................................................................................................................... 3
Q2............................................................................................................................... 4
Q2(a) Image(s)...................................................................................................... 4
Image Graph of Actor/Movie Relationship (Titles)..............................................4
Image Graph of Actor/Movie Relationship (Rating)............................................4
Q2(b) Cypher query to extract Tom Hanks............................................................5
Image Tom Hanks Query Results with Movie Titles............................................5
Image Tom Hanks Query Results with Ratings...................................................5
Q3............................................................................................................................... 6
Image Visual of Update to American Hustle Rating..............................................6

Q1
The cypher code below was used to create the database outlined in the assignment.
CREATE (:actor {name:"Kevin Bacon"});
CREATE (:actor {name:"Jennifer Lawrence"});
CREATE (:actor {name:"Amy Adams"});
CREATE (:actor {name:"Tom Hanks"});
CREATE (:movie {title:"Apollo 13", rating:"95"});
CREATE (:movie {title:"X-Men: First Class", rating:"87"});
CREATE (:movie {title:"American Hustle", rating:"93"});
CREATE (:movie {title:"Catch Me If You Can", rating:"96"});
MATCH (a:actor {name:"Kevin Bacon"}), (a:actor {name:"Jennifer Lawrence"}), (a:actor
{name:"Amy Adams"}), (a:actor {name:"Tom Hanks"}) RETURN a;
MATCH (b:movie {title:"Apollo 13"}), (b:movie {title:"X-Men: First Class"}), (b:movie
{title:"American Hustle"}), (b:movie {title:"Catch me If You Can"}) RETURN b;
MATCH ( a:actor {name:"Kevin Bacon"}), ( b:movie {title:"Apollo 13"}) CREATE (a)-[:Starring
{topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Kevin Bacon"}), ( b:movie {title:"X-Men: First Class"}) CREATE (a)[:Starring {topic:"casted in"}]->(b);

MATCH ( a:actor {name:"Jennifer Lawrence"}), ( b:movie {title:"X-Men: First Class"}) CREATE


(a)-[:Starring {topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Jennifer Lawrence"}), ( b:movie {title:"American Hustle"}) CREATE
(a)-[:Starring {topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Amy Adams"}), ( b:movie {title:"American Hustle"}) CREATE (a)[:Starring {topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Amy Adams"}), ( b:movie {title:"Catch Me If You Can"}) CREATE
(a)-[:Starring {topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Tom Hanks"}), ( b:movie {title:"Apollo 13"}) CREATE (a)-[:Starring
{topic:"casted in"}]->(b);
MATCH ( a:actor {name:"Tom Hanks"}), ( b:movie {title:"Catch Me If You Can"}) CREATE (a)[:Starring {topic:"casted in"}]->(b);

Q2
Q2(a) Image(s)
Image Graph of Actor/Movie Relationship (Titles)

Image Graph of Actor/Movie Relationship (Rating)

Q2(b) Cypher query to extract Tom Hanks


MATCH (n { name: 'Tom Hanks' })-[r]-() RETURN n, r;

Image Tom Hanks Query Results with Movie Titles

Image Tom Hanks Query Results with Ratings

Q3
MATCH (n:movie { title: "American Hustle" }) SET n.rating =86;

MATCH (b:movie { title:"American Hustle"} ) RETURN b;

Image Visual of Update to American Hustle Rating

You might also like