Rob Lachlan
Rob Lachlan

Reputation: 14479

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?

Upvotes: 12

Views: 8943

Answers (3)

Sridhar Ramachandran
Sridhar Ramachandran

Reputation: 187

Yes. Schemas useful in selecting vertex labels, which are part both Neo4J 2 and Tinkerpop 3. I think writing down the schema helps clarify how the graph should be used, although most databases don't support validations against a schema.

I have a longer post on how to draw the schema as a graph. http://lambdazen.blogspot.com/2014/01/do-property-graphs-have-schemas.html

Upvotes: 4

TobyTheDog
TobyTheDog

Reputation: 41

A graph database will always have a rudimentary schema consisting of (at least) Vertex and Edge objects, where an Edge can contain data about a particular relationship. The degree to which you can add to this schema varies widely across implementations. You may be able to customize the schema by inheriting from Edge and/or Vertex objects,for instance.

If the graph database uses an underlying RDBMS or ODBMS then you may have access to more powerful schema creation and manipulation capabilities.

Upvotes: 3

nawroth
nawroth

Reputation: 4361

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.

Upvotes: 4

Related Questions