How do document databases work?
Why are document db used?
What do vertices and edges represent in graph databases?
vertices:
- objects, things w/ attributes/properties (entities in ER model)
edges:
- relationships b/w
- directed, but searching can ignore direction
In Neo4J, what’s the syntas to create something with 2 attributes?
CREATE (Name:Label {key:value, key2:value2})
In Neo4J, create a Person Keanu reeves, with the name being just his first name and he’s born in 1964
CREATE (Keanu: Person {name:’Keanu Reeves’, born: 1964})
In Neo4J, create the relationship ACTED_IN between Keanu and the matrix. the property should include their role
CREATE (Keanu)-:[:ACTED_IN {roles:[‘Neo’]}]->(TheMatrix)
Describe how to represent a node and edge in Neo4J
() = node
[] = edge
- edges are always directional
What does MATCH and RETURN do here:
MATCH (a)-[]-(b) RETURN a,b
MATCH - searches for relationships satisfying the pattern
RETURN - specifies what is the result set
How to show everything about a movie?
MATCH (m:movie) RETURN m
How to search for a person named tom Hanks?
MATCH (tom:Person {name:”Tom Hanks”}) return tom
How to make a director and movie?
MATCH (p:Person)-[d:DIRECTED]->(m:Movie) RETURN p,d,m
Show the query to find person, director, and movie that was released after 2010
MATCH (p:Person)-[d:Directed]-(m:Movie) WHERE m.released>2010 RETURN p,d,m