Skip to content

Revert "add indexes and constraints content" #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions documentation/movies.workspace.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ image::movie-model.png[]

[source,cypher]
----
CREATE CONSTRAINT movie_title IF NOT EXISTS FOR (m:Movie) REQUIRE m.title IS UNIQUE;
CREATE CONSTRAINT person_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS UNIQUE;

MERGE (TheMatrix:Movie {title:'The Matrix'}) ON CREATE SET TheMatrix.released=1999, TheMatrix.tagline='Welcome to the Real World'

MERGE (Keanu:Person {name:'Keanu Reeves'}) ON CREATE SET Keanu.born=1964
Expand Down Expand Up @@ -699,22 +702,6 @@ MATCH path = (person)-[:ACTED_IN]->(m)<-[:DIRECTED]-(d)
RETURN path;
----

To aid query performance, you can add indexes to your data.
(The dataset you create in this guide is very small, but it is good practice to use indexes as they can greatly improve query performance when the datasets are larger.)

In this small dataset, you are mainly interested in names of people and titles of movies.
Run the following to add indexes on these properties

[source,cypher]
----
CREATE INDEX person_name FOR (p:Person) ON (p.name);
CREATE INDEX movie_title FOR (m:Movie) ON (m.title)
----

Note that you can also add constraints to your data to ensure uniqueness for example.
Adding constraints automatically adds a correpsonding index.
See link:https://neo4j.com/docs/cypher-manual/current/constraints/[Cypher Manual -> Constraints^] for more information.

In the next step, you will look for nodes and their properties.

== Find nodes
Expand Down