Skip to content

Conversation

@lidiazuin
Copy link
Contributor

No description provided.

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also very useful! Left some comments!

= Defining a schema

This guide explains how to define a schema by using indexes and constraints.
While Neo4j is often described as _schema optional_, indexes and constraints can be introduced when desired, in order to gain performance or xref:data-modeling/index.adoc[modeling] benefits.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
While Neo4j is often described as _schema optional_, indexes and constraints can be introduced when desired, in order to gain performance or xref:data-modeling/index.adoc[modeling] benefits.
While Neo4j is often described as _schema optional_, indexes and constraints can be added when needed, either for performance optimization or xref:data-modeling/index.adoc[modeling] benefits.

I don't really understand what modelling has to do with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure either, it's from the original content. Should we remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it IS related. Maybe it can be rephrased to make it clearer?

== Example graph

First create some data to use for our examples:
After you create a link:https://neo4j.com/product/auradb/?ref=docs-nav-get-started[free Aura instance], use the "Connect" button and select "Query".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does read a bit weird "After you create..." like it's a prerequisite, but it's not stated anywhere that it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were using the same instruction for previous tutorials, but since this is a guide, maybe it's better to write this differently.


The main reason for using indexes in a graph database is to find the starting point of a graph traversal.
The main reason for using link:https://neo4j.com/docs/cypher-manual/current/indexes/[indexes] in a graph database is to find the starting point of a graph traversal.
Once that starting point is found, the traversal relies on in-graph structures to achieve high performance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To achieve high performance?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still sounds strange, "to achieve high performance". What "in-graph"structures" are you referring to? The actual graph structure (vs relational tables)?


=== Find constraints

First, you need to create a constraint.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header says "Find restraint". It seems counterintuitive to have to create something in order to find it.
Maybe we should have an example of how to create a constraint first and then how to find it?

Copy link
Contributor

@AlexicaWright AlexicaWright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking shape! Some more comments.


The main reason for using indexes in a graph database is to find the starting point of a graph traversal.
The main reason for using link:https://neo4j.com/docs/cypher-manual/current/indexes/[indexes] in a graph database is to find the starting point of a graph traversal.
Once that starting point is found, the traversal relies on in-graph structures to achieve high performance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still sounds strange, "to achieve high performance". What "in-graph"structures" are you referring to? The actual graph structure (vs relational tables)?

The main reason for using indexes in a graph database is to find the starting point of a graph traversal.
The main reason for using link:https://neo4j.com/docs/cypher-manual/current/indexes/[indexes] in a graph database is to find the starting point of a graph traversal and thus achieve high performance.
Once that starting point is found, the traversal relies on in-graph structures to achieve high performance.
Moreover, indexes can be added at any point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Moreover, indexes can be added at any point.
Indexes can be added at any point.

"Moreover" sounds very formal and the sentence that follows doesn't really strengthen the first paragraph, it just adds information. I'd suggest to just move the sentence to a new line for the same effect, but make it sound less formal.

This is one of several options for query tuning, described in detail in link:{neo4j-docs-base-uri}/cypher-manual/current/query-tuning[Cypher manual -> Query tuning].
====
In most cases, it is not necessary to specify which index to use when querying for data, as the appropriate indexes are used automatically.
However, you can still use index hints to specify which index to use in a particular query.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add something on why you'd want to do that when it's already done automagically?


[source, cypher]
--
SHOW INDEXES YIELD name, labelsOrTypes, properties, type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's incorrect syntax, use just SHOW INDEXES and you'll get ALL the details.

Constraints are used to make sure that the data adheres to the rules of the domain.
For example:
link:https://neo4j.com/docs/cypher-manual/current/constraints/[Constraints] are used to make sure that the data adheres to the rules of the domain.
They can be property uniqueness contraints, property existence, property type, or key constraints.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
They can be property uniqueness contraints, property existence, property type, or key constraints.
They can be property uniqueness, property existence, property type, or key constraints.


|===

Constraints can be added to databases that already have data in them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to say that they cannot be added to empty dbs?

|===

Constraints can be added to databases that already have data in them.
However, this requires that the existing data complies with the constraint that is being added.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if existing data does not comply with an added constraint?

--
CREATE CONSTRAINT constraint_example_1 FOR (movie:Movie) REQUIRE movie.title IS UNIQUE
----
--
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth mentioning that when you create some constraints, a corresponding index is automatically created? This constraint results in a range index on the title property of movie nodes. If you run SHOW INDEXES after you create the constraint, you can see it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some constraints, as in specific cases, or any constraint? Because if it's only some, then it might need more explanation, and I guess it's better to keep it short in the GSG

If there is existing data in the database, it will take some time for an index to come online.
====
link:https://neo4j.com/docs/cypher-manual/current/indexes/[Indexes] are used for speeding up data retrieval and thus improve performance.
They can be added at any point.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
They can be added at any point.
They can be added at any time.

It is possible to specify which index to use in a particular query, using _index hints_.
This is one of several options for query tuning, described in detail in link:{neo4j-docs-base-uri}/cypher-manual/current/query-tuning[Cypher manual -> Query tuning].
====
In most cases, it is not necessary to specify which index to use when querying for data, as the appropriate indexes are used automatically.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In most cases, it is not necessary to specify which index to use when querying for data, as the appropriate indexes are used automatically.
Cypher's query planner automatically selects the appropriate index to use for your query.
Only in exceptional cases do you need to specify which index to use.
See link:{neo4j-docs-base-uri}/cypher-manual/current/indexes/search-performance-indexes/index-hints/[Cypher Manual -> Index hints for the Cypher planner] for more information.

@neo4j-docops-agent
Copy link
Collaborator

This PR includes documentation updates
View the updated docs at https://neo4j-docs-getting-started-512.surge.sh

Updated pages:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants