Skip to content
Open
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
72 changes: 42 additions & 30 deletions pages/querying/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -376,24 +376,26 @@ This procedure is also exposed as `apoc.meta.nodeTypeProperties` and

- `nodeType: string` ➡ Concatenated node labels separated by a `:`.
- `nodeLabels: List[string]` ➡ A list of node labels.
- `propertyName: string` ➡ Property name.
- `propertyTypes: List[string]` ➡ Property types observed for this property on nodes of this type.
- `mandatory: boolean` ➡ Returns `True` if every node with a given node type (defined by nodeType or nodeLabels) possesses the listed property (propertyName), and `False` otherwise.
- `propertyName: string` ➡ Property name.
- `propertyTypes: string` ➡ Property type.
- `propertyObservations: integer` ➡ Number of nodes of this type that carried this property.
- `totalObservations: integer` ➡ Total number of nodes of this type that were examined (bounded by the `sample` config option).

{<h3 className="custom-header"> Usage: </h3>}

To get the information about nodes and properties, run the following query:

```cypher
CALL schema.node_type_properties()
YIELD nodeType, nodeLabels, mandatory, propertyName, propertyTypes;
YIELD nodeType, nodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

To restrict the scan to a subset of labels, pass a `config` map:

```cypher
CALL schema.node_type_properties({includeLabels: ["Dog"]})
YIELD nodeType, nodeLabels, mandatory, propertyName, propertyTypes;
YIELD nodeType, nodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

### rel_type_properties()
Expand Down Expand Up @@ -423,9 +425,15 @@ This procedure is also exposed as `apoc.meta.relTypeProperties` and
{<h3 className="custom-header"> Output: </h3>}

- `relType: string` ➡ The type of the relationship.
- `mandatory: boolean` ➡ Returns `True` if every relationship with a given relationship type (defined by relType) possesses the listed property (propertyName), and `False` otherwise.
- `sourceNodeLabels: List[string]` ➡ Labels on the start node of relationships in this partition.
- `targetNodeLabels: List[string]` ➡ Labels on the end node of relationships in this partition.
- `propertyName: string` ➡ Property name.
- `propertyTypes: string` ➡ Property type.
- `propertyTypes: List[string]` ➡ Property types observed for this property on relationships in this partition.
- `mandatory: boolean` ➡ Returns `True` if every relationship in this partition possesses the listed property, and `False` otherwise.
- `propertyObservations: integer` ➡ Number of relationships in this partition that carried this property.
- `totalObservations: integer` ➡ Total number of relationships in this partition that were examined.

One row is emitted per `(relType, sourceNodeLabels, targetNodeLabels, propertyName)` combination. The same relationship type connecting different label sets (for example `(:Dog)-[:LOVES]->(:Activity)` vs `(:Cat)-[:LOVES]->(:Place)`) produces separate rows, so each partition can be characterised independently.

{<h3 className="custom-header"> Usage: </h3>}

Expand All @@ -434,14 +442,14 @@ To get the information about relationships and properties, run the following que

```cypher
CALL schema.rel_type_properties()
YIELD relType, mandatory, propertyName, propertyTypes;
YIELD relType, sourceNodeLabels, targetNodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

To restrict the scan to a subset of relationship types, pass a `config` map:

```cypher
CALL schema.rel_type_properties({includeRels: ["LOVES"]})
YIELD relType, mandatory, propertyName, propertyTypes;
YIELD relType, sourceNodeLabels, targetNodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

### assert()
Expand Down Expand Up @@ -517,7 +525,7 @@ Results:
+-----------------------------------------------------------------------------+
| "Created" | "[name, surname]" | ["name", "surname"] | "Person" | true |
+-----------------------------------------------------------------------------+
| "Kept" | "id" | ["id"] | "Person" | true |
| "Kept" | "[id]" | ["id"] | "Person" | true |
+-----------------------------------------------------------------------------+
```

Expand Down Expand Up @@ -555,41 +563,45 @@ Call the procedure to get information about the nodes:

```cypher
CALL schema.node_type_properties()
YIELD nodeType, nodeLabels, mandatory, propertyName, propertyTypes;
YIELD nodeType, nodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

Result:

```plaintext
+--------------------+--------------------+--------------------+--------------------+--------------------+
| nodeType | nodeLabels | mandatory | propertyName | propertyTypes |
+--------------------+--------------------+--------------------+--------------------+--------------------+
| ":`Sky`" | ["Sky"] | false | "" | "" |
| ":`Park`" | ["Park"] | false | "" | "" |
| ":`Human`:`Owner`" | ["Human", "Owner"] | false | "age" | "Int" |
| ":`Human`:`Owner`" | ["Human", "Owner"] | false | "name" | "String" |
| ":`Bird`" | ["Bird"] | false | "" | "" |
| ":`Dog`" | ["Dog"] | false | "age" | "Int" |
| ":`Dog`" | ["Dog"] | false | "name" | "String" |
+--------------------+--------------------+--------------------+--------------------+--------------------+
+--------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
| nodeType | nodeLabels | propertyName | propertyTypes | mandatory | propertyObservations | totalObservations |
+--------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
| ":`Bird`" | ["Bird"] | "" | [] | false | 0 | 1 |
| ":`Dog`" | ["Dog"] | "age" | ["Int"] | false | 1 | 2 |
| ":`Dog`" | ["Dog"] | "name" | ["String"] | false | 1 | 2 |
| ":`Human`:`Owner`" | ["Human", "Owner"] | "age" | ["Int"] | true | 1 | 1 |
| ":`Human`:`Owner`" | ["Human", "Owner"] | "name" | ["String"] | true | 1 | 1 |
| ":`Park`" | ["Park"] | "" | [] | false | 0 | 1 |
| ":`Sky`" | ["Sky"] | "" | [] | false | 0 | 1 |
+--------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
```

Of the two `:Dog` nodes, only one carries `name` and `age` — hence `propertyObservations = 1`, `totalObservations = 2`, and `mandatory = false`. The single `:Human:Owner` node has both properties, so they are marked mandatory.

Call the procedure to get information about the relationships:

```cypher
CALL schema.rel_type_properties()
YIELD relType, mandatory, propertyName, propertyTypes;
YIELD relType, sourceNodeLabels, targetNodeLabels, propertyName, propertyTypes, mandatory, propertyObservations, totalObservations;
```

Results:

```plaintext
+------------------------+------------------------+------------------------+------------------------+
| relType | mandatory | propertyName | propertyTypes |
+------------------------+------------------------+------------------------+------------------------+
| ":`FLIES_TO`" | false | "" | "" |
| ":`RUNS_AND_PLAYS_IN`" | false | "duration" | "String" |
| ":`RUNS_AND_PLAYS_IN`" | false | "speed" | "Int" |
| ":`LOVES`" | true | "how_much" | "String" |
+------------------------+------------------------+------------------------+------------------------+
+------------------------+------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
| relType | sourceNodeLabels | targetNodeLabels | propertyName | propertyTypes | mandatory | propertyObservations | totalObservations |
+------------------------+------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
| ":`FLIES_TO`" | ["Bird"] | ["Sky"] | "" | [] | false | 0 | 1 |
| ":`LOVES`" | ["Dog"] | ["Human", "Owner"] | "how_much" | ["String"] | true | 1 | 1 |
| ":`RUNS_AND_PLAYS_IN`" | ["Dog"] | ["Park"] | "duration" | ["String"] | true | 1 | 1 |
| ":`RUNS_AND_PLAYS_IN`" | ["Dog"] | ["Park"] | "speed" | ["Int"] | true | 1 | 1 |
+------------------------+------------------+--------------------+--------------+----------------+-----------+----------------------+--------------------+
```

Each row is keyed by the relationship type *together with* the labels on the start and end nodes. If the dataset had another `:LOVES` relationship between different label sets (for example `(:Cat)-[:LOVES]->(:Activity)`), it would appear on its own row rather than being merged into the existing `:LOVES` partition.