Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there such a thing as a schema in a graph database?

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?

like image 709
Rob Lachlan Avatar asked Jul 29 '11 18:07

Rob Lachlan


People also ask

What is a graph schema?

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.

Does Neo4j have a schema?

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.

What are the 3 types of database schema?

Schema is of three types: Logical Schema, Physical Schema and view Schema.


1 Answers

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:

  • Defining the schema in annotations, for example using Spring Data Graph (docs).
  • Using a meta-model layer on top of the database.

You'll find some more reading on this topic over at myNoSQL.

like image 171
nawroth Avatar answered Nov 16 '22 00:11

nawroth