Range of graph database use cases broadens and new application - - PowerPoint PPT Presentation

range of graph database use cases broadens and new
SMART_READER_LITE
LIVE PREVIEW

Range of graph database use cases broadens and new application - - PowerPoint PPT Presentation

Range of graph database use cases broadens and new application requirements emerge One such requirement: solutions to specify rigid forms of logical schemas What does a valid instance has to look like? What constraints does it have


slide-1
SLIDE 1

1 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

  • Range of graph database use cases broadens

and new application requirements emerge

  • One such requirement: solutions to

specify rigid forms of logical schemas

– What does a valid instance has to look like? – What constraints does it have to satisfy?

  • RDF has SHACL and ShEx
  • Property Graphs? No commonly agreed-upon approach
slide-2
SLIDE 2

2 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

slide-3
SLIDE 3

3 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

So what?

  • GraphQL APIs are based on some form of schema
  • Specified in a developer-friendly language

Research Question: Can the GraphQL Schema Definition Language be repurposed to also define schemas for Property Graphs?

slide-4
SLIDE 4

Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language

Olaf Hartjga, Jan Hidders b

(a) Dept. of Computer and Informatjon Science, Linköping University, Sweden (b) currently unaffjliated

slide-5
SLIDE 5

5 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Our Contributjons

Approach to adopt the GraphQL SDL for Property Graph schemas, incl. formal definition of the approach Formalization of the notion of schema as captured by the GraphQL SDL Fundamental properties of the approach

(validation problem is in AC0; checking satisfiability

  • f schemas is NP-hard and in PSPACE)
slide-6
SLIDE 6

GraphQL Schemas in a Nutshell

slide-7
SLIDE 7

7 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

GraphQL Schemas in a Nutshell

declaration of an object type with its fields and their types argument declaration of an object type with its fields and their types declaration of an interface type and an implementation declaration of a union type declaration of a union type declaration of the query type (possible root fields of queries)

slide-8
SLIDE 8

Overview of the Approach

slide-9
SLIDE 9

9 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Specifying Types of Nodes using Object Type Defjnitjons

  • Defines three types of nodes: nodes with the label User,

nodes with the label Post, and nodes with the label Section

We assume only one label per node

Post User User

type User { … } type Post { … } type Section { … }

Section Section

slide-10
SLIDE 10

10 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

type User { login: String! nicknames: [String!]! } type Post { … } type Section { … }

Specifying Node Propertjes using Field Defjnitjons that are based on scalar types

  • User nodes may have two properties, login and nicknames

Post User login: "bob23" nicknames: ["Bobby", "Bob"] User login: "ali" Section Section

slide-11
SLIDE 11

11 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

type User @key(fields:["login"]) { login: String! @required nicknames: [String!]! } type Post { … } type Section { … }

Constraints on Node Propertjes using Directjves

  • User nodes may have two properties, login and nicknames
  • login property required
  • login property is a key (i.e., values must be unique)

Post User login: "bob23" nicknames: ["Bobby", "Bob"] User login: "ali" Section Section

slide-12
SLIDE 12

12 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Section Section Post User User login: "ali" author sec sec

type User @key(fields:["login"]) { login: String! @required nicknames: [String!]! } type Post { author: User! sec: [Section!]! } type Section { … }

Specifying Types of Outgoing Edges using Field Defjnitjons that are based on object types

  • Post nodes may have an author edge pointing to a User node
  • Post nodes may have several sec edges to Section nodes

login: "bob23" nicknames: ["Bobby", "Bob"]

slide-13
SLIDE 13

13 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

type User @key(fields:["login"]) { login: String! @required nicknames: [String!]! } type Post { author: User! @required sec: [Section!]! @distinct @requiredForTarget } type Section { … }

Constraints on Edge Types using Directjves

  • every Post node must have an (outgoing) author edge
  • all sec edges of a Post node must point to different Section nodes
  • every Section node must have at least one incoming sec edges

Section Section Post User login: "bob23" nicknames: ["Bobby", "Bob"] User login: "ali" author sec sec

slide-14
SLIDE 14

14 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

type User @key(fields:["login"]) { login: String! @required nicknames: [String!]! } type Post { author: User! sec: [Section!]! @distinct @requiredForTarget } type Section { … }

Constraints on Edge Types using Directjves (cont'd)

  • @noloop: edges cannot connect a node with itself
  • @uniqueForTarget: nodes that are target of a given edge type can

have at most one incoming edge of this type

Section Section Post User login: "bob23" nicknames: ["Bobby", "Bob"] User login: "ali" author sec sec

slide-15
SLIDE 15

15 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Specifying Edges with Multjple Target Types using Unions

  • Every Person node may have a favoriteVehicle edge

pointing either to a Motorcycle node or to a Car node

Motor- cycle Person name: "Alice" favoriteVehicle … Car Person name: "Bob" favoriteVehicle …

type Person { name: String! favoriteVehicle: Vehicle } union Vehicle = Car | Motorcycle type Motorcycle { … } type Car { … }

slide-16
SLIDE 16

16 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Motor- cycle Person name: "Alice" favoriteVehicle

type Person { name: String! favoriteVehicle: Vehicle } interface Vehicle { … } type Motorcycle implements Vehicle { … } type Car implements Vehicle { … }

Specifying Edges with Multjple Target Types using Interfaces

  • Every Person node may have a favoriteVehicle edge

pointing either to a Motorcycle node or to a Car node

… Car Person name: "Bob" favoriteVehicle …

slide-17
SLIDE 17

17 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Author name: "Bob" influencedBy

Specifying Edge Propertjes using Field Argument Defjnitjons

  • Every influencedBy edge (between Author nodes) may have

a significance property with a floating point number as value

type Author { name: String! influencedBy(significance: Float): [Author!]! }

Author name: "Alice" significance: 0.8

slide-18
SLIDE 18

Propertjes of the Approach

slide-19
SLIDE 19

19 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Schema Validatjon Problem

Definition: Given a Property Graph G and a GraphQL schema S, does G strongly satisfy S? Theorem*: Under the assumption that

– the set of scalar types is fixed and finite, and – the problem of deciding if a given scalar value

is of a given scalar type is in AC0, the computational complexity of the schema validation problem is in AC0.

*expressed more formally in the paper

slide-20
SLIDE 20

21 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Not all schemas are satjsfjable

type OT1 { } interface IT { hasOT1: OT1 @uniqueForTarget } type OT2 implements IT { hasOT1: [OT1] @requiredForTarget } type OT3 implements IT { hasOT1: [OT1] @requiredForTarget }

  • Assume OT1 node n1
  • n1 must have in-edge

from an OT2 node n2

  • n1 must have in-edge

from an OT3 node n3

  • n1 can have at most
  • ne such in-edge
  • thus, n2 = n3,

which contradicts that nodes can have only

  • ne label/type
slide-21
SLIDE 21

22 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Object-Type Satjsfactjon Problem

Definition: Given a GraphQL schema S and an object type ot in S, is there a Property Graph that strongly satisfy S and contains at least one node of type ot? Theorem: The object-type satisfiability problem is NP-hard. Theorem: The object-type satisfiability problem is in PSPACE.

slide-22
SLIDE 22

Summary and Outlook

slide-23
SLIDE 23

24 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Our Contributjons in a Nutshell

Approach to adopt the GraphQL SDL for Property Graph schemas, incl. formal definition of the approach Formalization of the notion of schema as captured by the GraphQL SDL Fundamental properties of the approach

  • validation problem is in AC0
  • checking satisfiability of schemas

is NP-hard and in PSPACE

slide-24
SLIDE 24

25 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Future Work

  • Characterize the computational complexity
  • f schema satisfiability more precisely
  • Approach to generate a GraphQL API based
  • n an SDL-based Property Graph schema

– Basis: the SDL-based Property Graph schema

must be extended into a GraphQL API schema

slide-25
SLIDE 25

26 Defjning Property Graph Schemas by using the GraphQL Schema Defjnitjon Language Olaf Hartjg, Jan Hidders

Our Other GraphQL-Related Research Work

  • Semantics and Complexity of GraphQL

– Evaluation problem is NL-complete (combined complexity) – Algorithm to compute result size in polynomial time

  • An Empirical Analysis of GraphQL API Schemas

– 2081 distinct schemas extracted from open code repos

  • Linköping GraphQL Benchmark (LinGBM)

– Ongoing work, see https://github.com/LiUGraphQL/LinGBM/ – Tests the performance of GraphQL server implementations – Designed based on the LDBC methodology – 16 “choke points” (technical challenges) – 16 query templates that cover the CPs – Synthetic datasets (RDB, RDF) of arbitrary size

slide-26
SLIDE 26

www.liu.se