12

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?

Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
  • 1
    Bear in mind that graph databases are far from being as standardized as relational databases adhering to a certain SQL version. So I think it depends on what graph database you use. – das_weezul Jul 29 '11 at 18:31

3 Answers3

4

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

4

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.

Community
  • 1
  • 1
nawroth
  • 4,321
  • 1
  • 24
  • 21
3

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.

TobyTheDog
  • 41
  • 1