0% found this document useful (0 votes)
11 views2 pages

Cypher Queries for Movie Database

The document contains a series of Cypher queries designed to extract information from a database related to movies and people involved in them. It includes queries for retrieving names, roles, relationships, and specific details about movies and individuals like actors, directors, and writers. Each query is structured to return relevant data based on various criteria, such as movie titles and person names.

Uploaded by

Nistha choudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Cypher Queries for Movie Database

The document contains a series of Cypher queries designed to extract information from a database related to movies and people involved in them. It includes queries for retrieving names, roles, relationships, and specific details about movies and individuals like actors, directors, and writers. Each query is structured to return relevant data based on various criteria, such as movie titles and person names.

Uploaded by

Nistha choudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Q1 All nodes in db

Ans match (n) return n


Q2 Names of people in db
Ans match (n:Person)
return [Link] as Name
Q3 Names of everybody in th db with names or peoples name.
Ans match (n:Person)
return [Link] as `People's Name`
Q4 Names of actors, directors and producers in the db.
Ans match (n:Person)-[:ACTED_IN]->(:Movie),(q:Person)-[:DIRECTED]->(:Movie),
(r:Person)-[:PRODUCED]->(:Movie)
return [Link] as `Actor's Name`, [Link] as `Director's Name`, [Link] as
`Producre's Name`
Q5 Know the relationship exists in db?
Ans match()-[r]-()
return distinct(type(r)) as `Relationship type`
Q6 Name of each person with work he/she did in movies and movie name.
Ans match(p:Person)-[r]->(m:Movie)
return [Link] as `Name`,type(r) as `Work`,[Link] as `Movie' Name`
Q7 What did Steve Zahn do in "You've Got Mail"? Also what role did Carrie Fisher
played in "When Harry Met Sally".
Ans match(p:Person{name:'Steve Zahn'})-[r]->(m:Movie{title:"You've Got Mail"})
return type(r) as `Work`
match(p:Person{name:'Carrie Fisher'})-[r]->(m:Movie{title:"When Harry Met
Sally"})
return type(r) as `Work`
match(p:Person{name:'Carrie Fisher'})-[r]->(m:Movie{title:"When Harry Met
Sally"})
return [Link] as `Work`
match(p:Person{name:'Carrie Fisher'})-[r]->(m:Movie{title:"When Harry Met
Sally"})
return 'Carrie Fisher\'s role in When Harry Met Sally was' + [Link] as `Carrie
Fisher`
match(p:Person{name:'Carrie Fisher'})-[r]->(m:Movie{title:"When Harry Met
Sally"})
return 'Carrie Fisher'+' ' + type(r)+' '+'in When Harry Met Sally was' as
Sentence
Q8 There is a movie titled "Cast Away" in the db. What cypher query would u use to
view the node?
Ans match (m:Movie{title:'Cast Away'}) //(to return any node)
return *
// to reutn all nodes match(m:Movies) return m or *
Q9 The titles of the moie where Tom Tykwer was involved also what he did?
Ans match (n:Person{name:'Tom Tykwer'})-[r]-(m:Movie)
return type(r) ,[Link] as `Title`
Q10 Tom Hanks Acted in many movies. provide title of the movie and roles he played
Ans match (n:Person{name:'Tom Hanks'})-[r]-(m:Movie)
return [Link] as `Roles` ,[Link] as `Title`
Note://since the role of the thing you do is missing to find out this
match (n:Person{name:'Tom Hanks'})-[r]-(m:Movie{title:"That Thing You Do"})

return type(r)
Q11 How many relationship are there in db?
Ans match()-[r]-()
return count(type(r))
Q12 How many nodes are in the relationship?
Ans match(n)
return count(n)
Q13 Who are those people that were involved in a movie titled "The Da Vinci Code".
Give their names coresspoinding to their work?
Ans match(n)-[r]->(m:Movie{title:'The Da Vinci Code'})
return [Link] as `People who were involved`,type(r) as `Work`
Q14 Do we have writers in db. If yes please give their name
Ans match(n:Person)-[r:WROTE]->(m:Movie)
return distinct([Link]) as `Writer's NAme`
Q15 Name of those who wrote or produced a movie with their role and movie name?
Ans match(n:Person)-[r:PRODUCED|WROTE]->(m:Movie)
return [Link] as` Name`, type(r) as `Role`,[Link] as ` Work`
Q16 Name of those who wrote or produced a movie
Ans match(n:Person)-[r:PRODUCED|WROTE]->(m:Movie)
return [Link] as` Name`, type(r) as `Role`
match(n)-[:PRODUCED]->(m)<-[:WROTE]-(n)
return [Link] as` Name`
match(n)-[:PRODUCED]->(m)<-[:WROTE]-(n)
return n,m
Q17 Write a query to fetch the nodes of people who wrote,produced and directed same
movie. The connection to movie should also be displayed?
Ans match(n)-[:PRODUCED]->(m)<-[:WROTE]-(n),(n)-[:DIRECTED]->(m)
return [Link] as`Name of people who directed, wrote and produced a
movie` ,[Link] as `Movie name`
To produce node:-match(n)-[:PRODUCED]->(m)<-[:WROTE]-(n),(n)-[:DIRECTED]->(m)
return *
Q18 Name of the people who performed three task in a movie aat same time with there
task name?
Ans match(p)-[r]->(m:Movie)<-[s]-(p),(p)-[t]->(m:Movie)
return [Link] as `Name`, type(r),type(s),type(t)
To produce node:-match(p)-[r]->(m:Movie)<-[s]-(p),(p)-[t]->(m:Movie)
return p,m
Q19 Get the names of people that have performd two task on a movieat same time.
These same people performed another two task on another movie. find movie
name, their role and name and task?
Ans match(p1)-[]->(m1:Movie)<-[]-(p1),(p2)-[]->(m1:Movie)<-[]-(p2),(p1)-[]-
>(m2:Movie)<-[]-(p1),(p2)-[]->(m2:Movie)<-[]-(p2)
return *
Q20 Who reviewed the movie titiled"The Birdcage"?
Ans match (n:Person)-[:REVIEWED]->(m:Movie{title:"The Birdcage"})
return *
Q21 Who directed the movie acted by Ian [Link] name of movie and the
director?
Ans match(n:Person{name:"Ian McKellen"})-[:ACTED_IN]->(m:Movie)<-[:DIRECTED]-(d)
return *
match(n:Person{name:"Ian McKellen"})-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
return [Link] as `Director's Name`,[Link] as `Movie Title`
Q22 What is the title of the movie that was directed or written by Cameron Crowe?
Ans match(n:Person{name:'Cameron Crowe'})-[:DIRECTED|WROTE]->(m:Movie)
return [Link]
Q23 What is the title of the movie that was directed and written by Cameron Crowe?
Ans match(n:Person{name:'Cameron Crowe'})-[:DIRECTED ]->(m:Movie)<-[:WROTE]-
(n:Person{name:'Cameron Crowe'})
return [Link]
Q24 Load csv file from link: "[Link]
use WITH HEADER. USe different querry to convert data type
Ans

You might also like