Hi all,

As we move ahead toward schema support in TinkerPop, one of the concerns we
need to keep in mind is future interoperability with GQL
<https://www.gqlstandards.org/>, the ISO standard property graph query
language which is currently under development. GQL will encompass a
formally-defined data model and schema language for property graphs. One of
the most important inputs to GQL, in terms of schema, is the Property Graph
Schema Working Group (PGSWG
<https://3.basecamp.com/4100172/projects/10013370>), which is concerned
with coming up with that formal data model. While PGSWG is not open to the
public, it is easy enough to become a member of LDBC if you would like to
get involved (feel free to ping me if so). You can also request access to this
doc
<https://docs.google.com/document/d/16ozf76GlEq-YPZa0UJVj8gG6GgUeL_x9M5Wj35JiZP0/edit>
if you would like some insight into the discussion around property types,
which is the topic of the subgroup I lead. What is an appropriate type
system for property values, and by extension, graph elements? In this email
thread, I would like to expose some of the issues we have been discussing
to the TinkerPop community, and get your feedback. While TinkerPop's schema
language will not be based directly on GQL (for one thing, the
specification probably will not be ready for at least another year), it is
important to aim for compatibility, as this is what the major graph vendors
will be expected to implement in the future, if all goes well. There is
also an opportunity for TinkerPop to lead the way and demonstrate
applications of such a schema language in advance of a standard, which in
turn will inform the standard.

Without trying to give an exhaustive overview at this time, here are some
things I would like to mention:

   - *Prescriptive vs. descriptive schemas*. This is very important for
   property graphs. Whereas TinkerPop and most other PG solutions are
   relatively schema-less, there is strong motivation for a real,
   vendor-neutral schema language, which is what is driving the PGSWG. At the
   same time, a solution which requires all graph data to strictly conform to
   a schema in all contexts would not be supportive of typical applications,
   so there needs to be a spectrum. We are still discussing ways in which to
   provide the flexibility of schemas which describe parts of a graph and help
   with validation and inference over those parts, but which are tolerant of
   "other stuff" which goes beyond the schema. For TinkerPop, I think it will
   be simplest to start out with a binary world: either your graph is
   schemaless, i.e. you just don't have or just don't care about a schema, or
   it is expected to strictly conform to a predefined schema. Long-term, we
   are likely to move toward more of a true spectrum, and I think it's
   reasonably clear how to make that transition. In the beginning, you either
   have a schema or you don't.


   - *Algebraic types*. After all of the discussions I have had in the
   working group, at my company, and in the graph community, I still find
   algebraic data types to be the most promising basis for a TinkerPop schema
   language, and this is essentially what I am recommending for GQL as well.
   The initial proposal to GQL will include a kind of "everything but the
   kitchen sink" type grammar which has algebraic as well as non-algebraic
   type constructors (allowing implementations to pick and choose based on
   what works for them), but in TinkerPop I think we can be more focused, and
   I would welcome any discussion around this topic. By algebraic data types,
   I mean products (records) and sums (unions), together with primitives and
   named types (labels) along the lines of Algebraic Property Graphs (APG
   <https://arxiv.org/abs/1909.04881>). An algebraic type system of this
   kind has the advantage of being very straightforward to reason about, while
   also being well aligned with enterprise data languages. There will be
   other, more detailed posts from me to this list on the type system I
   propose to use in TinkerPop.


   - *Atomic types*. As part of the basic type system for property graphs,
   there is broad agreement that there should be a collection of predefined
   atomic types (called "primitive types" in the APG paper and in Dragon) like
   integers, floating-point numbers, character strings, and booleans. There is
   also agreement within the property types group that this collection of
   atomic types may be infinite, and that parameterization of atomic types
   should not be part of the standard schema language. For example, in
   addition to a 32-bit integer type, you might also have a 16-bit integer
   type, a 64-bit integer type, and so on... potentially any number of
   "integer" data types related to each other by a parameter. In GQL, these
   will likely just be given names like int32, int16, etc. and it will be up
   to implementations to determine the internal structure of the types, if
   any. Other possible parameters for integer types, for example, are
   signedness and width encoding. In TinkerPop, I suspect that we will take a
   slightly different approach (and one similar to Dragon) in that the grammar
   will in fact provide vocabulary for type parameters, and we will endeavor
   to make the parameter language expressive enough to serve the needs of most
   graph vendors. That makes the parameterization accessible to programming
   logic for optimizing Gremlin traversals, optimizing graph encodings, etc.
   However, all of this is to be discussed in detail on the dev list.


   - *Nominal vs. structural typing*. Another major area of discussion
   within PGSWG concerns the degree to which property graph schemas should be
   provided up front by the developer, vs. inferred from the structure of the
   graph. In my (enterprise) world, this choice is a no-brainer: you need to
   provide a schema up front -- where you know what type to expect for each
   graph element, and by type inference, of every unit of data in the graph --
   which will avoid all sorts of unnecessary data integration challenges.
   However, there are compelling use cases for a more bottom-up approach in
   which the schema is discovered as you go. In a nominally typed world, types
   have names, you know which type to impose on any given value in the graph,
   and two values which are structurally the same (e.g. a pair of doubles
   representing a latitude and longitude, versus a pair of doubles
   representing the min and max value of a range) may be unequal by virtue of
   the expected type. In PGSWG, I think we are pretty close to a solution
   which will support variations of both scenarios, but in TinkerPop again I
   would suggest starting with simplicity and strict nominal typing, then
   relaxing our solution in order to accommodate additional use cases.

That's probably a long enough email for now. I am happy to delve deeper
into any of the above, and I will continue to raise new topics on this list.

Josh

Reply via email to