This repository was archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
[master < schema] Write schema docs #1030
Open
mpintaric55334
wants to merge
2
commits into
master
Choose a base branch
from
E-add-schema-functions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
id: schema | ||
title: schema | ||
sidebar_label: schema | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
import RunOnSubgraph from '../../templates/_run_on_subgraph.mdx'; | ||
|
||
export const Highlight = ({children, color}) => ( | ||
<span | ||
style={{ | ||
backgroundColor: color, | ||
borderRadius: '2px', | ||
color: '#fff', | ||
padding: '0.2rem', | ||
}}> | ||
{children} | ||
</span> | ||
); | ||
|
||
|
||
The `schema` module offers procedures that allow you to interact with and retrieve information about the database schema. | ||
|
||
[](https://github.com/memgraph/mage/tree/main/cpp/schema_module) | ||
|
||
| Trait | Value | | ||
| ------------------- | ----------------------------------------------------- | | ||
| **Module type** | <Highlight color="#FB6E00">**util**</Highlight> | | ||
| **Implementation** | <Highlight color="#FB6E00">**C++**</Highlight> | | ||
| **Parallelism** | <Highlight color="#FB6E00">**sequential**</Highlight> | | ||
|
||
### Procedures | ||
|
||
### `node_type_properties()` | ||
|
||
This procedure returns schema information about nodes and their properties in the graph. For every property in a node, a separate row is created. | ||
|
||
#### Output: | ||
|
||
- `labels: List[string]` ➡ list of labels of the node. | ||
- `mandatory: boolean` ➡ a boolean which is `True` if the node has properties, `False` if the node has no properties. | ||
- `property_name: string` ➡ name of the property. | ||
- `property_type: string` ➡ type of the property. | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Usage: | ||
|
||
Cypher for creation of graph used in example: | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```cypher | ||
CREATE (d:Dog {name: "Rex", age: 5})-[l:LOVES {how_much: "very"}]->(h:Human:Owner {name: "Carl", age: 90}); | ||
CREATE (n:NonManadatoryNode); | ||
``` | ||
Cypher usage of the procedure: | ||
|
||
```cypher | ||
CALL schema.rel_type_properties() YIELD mandatory, property_name, property_type, rel_type RETURN mandatory, property_name, property_type, rel_type; | ||
``` | ||
|
||
```plaintext | ||
+-------------------------------------------------------------------+ | ||
| labels | mandatory | property_name | property_type | | ||
+-------------------------------------------------------------------+ | ||
| ["Dog"] | true | age | Int | | ||
+-------------------------------------------------------------------+ | ||
| ["Dog"] | true | name | String | | ||
+-------------------------------------------------------------------+ | ||
| ["Human", "Owner"] | true | age | Int | | ||
+-------------------------------------------------------------------+ | ||
| ["Human", "Owner"] | true | name | String | | ||
+-------------------------------------------------------------------+ | ||
| ["NonManadatoryNode"] | false | | | | ||
+-------------------------------------------------------------------+ | ||
``` | ||
|
||
|
||
### `rel_type_properties()` | ||
|
||
This procedure returns schema information about relationships and their properties in the graph. For every property in a relationship, a separate row is created. | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Output: | ||
|
||
- `rel_type: string` ➡ the type of the relationship. | ||
- `mandatory: boolean` ➡ a boolean which is `True` if the node has properties, `False` if the node has no properties. | ||
- `property_name: string` ➡ name of the property. | ||
- `property_type: string` ➡ type of the property. | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Usage: | ||
|
||
Cypher for creation of graph used in example: | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```cypher | ||
CREATE (d:Dog)-[r:RUNS_AND_PLAYS_IN {speed: 100, duration: "5 hours" }]->(p:Park); | ||
CREATE (b:Bird)-[f:FLIES_TO]->(s:Sky); | ||
``` | ||
Cypher usage of the procedure: | ||
|
||
```cypher | ||
CALL schema.rel_type_properties() YIELD rel_type, mandatory, property_name, property_type RETURN rel_type, mandatory, property_name, property_type; | ||
``` | ||
|
||
```plaintext | ||
+-------------------------------------------------------------------+ | ||
| labels | mandatory | property_name | property_type | | ||
+-------------------------------------------------------------------+ | ||
| RUNS_AND_PLAYS_IN | true | duration | String | | ||
+-------------------------------------------------------------------+ | ||
| RUNS_AND_PLAYS_IN | true | speed | Int | | ||
+-------------------------------------------------------------------+ | ||
| FLIES_TO | false | | | | ||
+-------------------------------------------------------------------+ | ||
|
||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.