Is there such a thing as a schema in a graph database? For example, can you specify which types of node can have relationships with which other types of node?
What does such a schema look like?
A graph schema is a "dictionary" that defines the types of entities, vertices and edges, in the graph and how those types of entities are related to one another. Each vertex or edge type has a name and a set of attributes (properties) associated with it.
A schema in Neo4j refers to indexes and constraints. Neo4j is often described as schema optional, meaning that it is not necessary to create indexes and constraints. You can create data — nodes, relationships and properties — without defining a schema up front.
Schema is of three types: Logical Schema, Physical Schema and view Schema.
Graph databases differ a lot in this area, just like das_weezul says. In the general case I think graph databases which are closer to object databases (OODB) also have built-in schema support. One nice thing about graph databases is that they're very well suited for mixing data and metadata. So a common approach for both dealing with schema support and security is to store this kind of metadata in a (sometimes hidden) part of the very same graph.
When it comes to Neo4j - where I'm on the team - there's currently at least two approaches in use for defining schemas:
You'll find some more reading on this topic over at myNoSQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With