Schema validation and evolution for PGs Eugenia Oshurko (ENS Lyon) 7 March 2019
Main ideas • Schema as a PG • Schema validation via graph homomorphisms • Schema nodes define node types • Schema relations define relations allowed between types • Properties on schema elements define sets of allowed properties • Schema/instance homomorphism allows to use existing tools from the graph transformation community 1/7
Update semantics • Sesqui-pushout (SqPO) rewriting approach • Rewriting given a rule and a matching of its left-hand side • Two phases • restrictive update: delete node/edge/property + clone node • expansive update: add node/edge/property + merge nodes L P R G + G G − 2/7
Schema/instance coupled updates Prescriptive updates • Deletion of schema elements can be propagated to data • We can clone schema nodes (split concepts) � clone of data nodes Descriptive updates • Creation of data elements can be propagated to schema • We can merge nodes of different types � merge of schema concepts Result: instance respects schema at all times 3/7
Prescriptive updates: example imageFile: STRING imageFile: STRING type: comment type: { post, comment } type: post L P l − Message Post Comment m S Message Person creationDate: 2010-10-30 firstName: Jose h browserUsed: Safari G lastName: Alonso type: comment imageFile: photo33711.jpg creationDate: 2010-10-16 n 3 n 6 HAS CREATOR browserUsed: Firefox type: post firstName: Jane HAS CREATOR H lastName: Murray A n 2 S K N O W C S R S W E A n 5 O N T LIKES K O R n 1 n 8 LIKES REPLY OF creationDate: 2010-10-30 firstName: Bryn browserUsed: { Firefox, Safari } lastName: Davies 4/7
Prescriptive updates: example imageFile: STRING? imageFile: STRING imageFile: STRING creationDate: STRING type: comment type: { post, comment } browserUsed: STRING type: post ... Post KNOWS L P HAS CREATOR l − Message Post Comment LIKES firstName: STRING R lastName: STRING E P gender: STRING Person L Y birthday: DATE O F ... LIKES m H A S O F C R E P L Y R E A T O R Comment S creationDate: STRING browserUsed: STRING Message Person ... creationDate: 2010-10-30 firstName: Jose h browserUsed: Safari G lastName: Alonso type: comment imageFile: photo33711.jpg creationDate: 2010-10-16 n 3 n 6 HAS CREATOR browserUsed: Firefox type: post firstName: Jane HAS CREATOR H lastName: Murray A n 2 S K N O W C S R S W E A n 5 O N T LIKES K O R n 1 n 8 LIKES REPLY OF creationDate: 2010-10-30 firstName: Bryn browserUsed: { Firefox, Safari } lastName: Davies 4/7
Prescriptive updates: example imageFile: STRING? imageFile: STRING imageFile: STRING creationDate: STRING type: comment type: { post, comment } browserUsed: STRING type: post ... Post KNOWS L P HAS CREATOR l − Message Post Comment LIKES firstName: STRING R lastName: STRING E P gender: STRING Person L Y birthday: DATE O F ... LIKES m H A S F O C R E P L Y E R A T O R Comment S creationDate: STRING browserUsed: STRING Message Person ... creationDate: 2010-10-30 creationDate: 2010-10-30 firstName: Jose firstName: Jose h browserUsed: Safari browserUsed: Safari lastName: Alonso G lastName: Alonso type: comment type: comment imageFile: photo33711.jpg imageFile: photo33711.jpg creationDate: 2010-10-16 n 3 n 6 HAS CREATOR creationDate: 2010-10-16 n 3 n 6 browserUsed: Firefox HAS CREATOR browserUsed: Firefox type: post type: post H firstName: Jane HAS CREATOR A firstName: Jane S HAS CREATOR HAS CREATOR lastName: Murray n 2 C H lastName: Murray R K A N n 2 E O S K A W S N O W T C S S O R W R S O n 5 W E N A n 5 LIKES O K N T LIKES K O R n 9 REPLY OF LIKES n 1 n 8 LIKES REPLY OF n 1 n 8 LIKES creationDate: 2010-10-30 REPLY OF browserUsed: creationDate: 2010-10-30 firstName: Bryn browserUsed: { Firefox, Safari } creationDate: 2010-10-30 firstName: Bryn lastName: Davies { Firefox, Safari } browserUsed: { Firefox, Safari } lastName: Davies 4/7
Descriptive updates: example R P a b ab m − m + firstName: Jose creationDate: 2010-10-30 firstName: Jose creationDate: 2010-10-30 G + G lastName: Alonso browserUsed: Safari lastName: Alonso browserUsed: Safari imageFile: photo33711.jpg imageFile: photo33711.jpg n 3 n 6 n 3 n 6 creationDate: 2010-10-16 HAS CREATOR creationDate: 2010-10-16 HAS CREATOR browserUsed: Firefox firstName: Jane browserUsed: Firefox firstName: Jane lastName: Murray lastName: Murray HAS CREATOR HAS CREATOR REPLY OF H K H N A n 2 A n 2 S O S K N W O S W C C S REPLY OF R R S S E W E W A n 5 O A n 5 O N T N T LIKES LIKES K O HAS CREATOR K O R R H A LIKES S C R E A T O S R E I K L n 1 n 8 n 1 n 4 n 7 LIKES REPLY OF LIKES REPLY OF firstName: Bryn creationDate: 2010-10-30 firstName: Bryn creationDate: 2010-10-30 creationDate: 2010-10-30 lastName: Davies browserUsed: { Firefox, Safari } lastName: Davies browserUsed: Firefox browserUsed: Safari imageFile: STRING? creationDate: STRING browserUsed: STRING ... Post KNOWS HAS CREATOR LIKES firstName: STRING R lastName: STRING E P gender: STRING Person L Y birthday: DATE O LIKES F ... H S A R E P L Y O F C R A E T O R Comment creationDate: STRING browserUsed: STRING ... 5/7
Descriptive updates: example R P a b ab m − m + firstName: Jose creationDate: 2010-10-30 firstName: Jose creationDate: 2010-10-30 G + G lastName: Alonso browserUsed: Safari lastName: Alonso browserUsed: Safari imageFile: photo33711.jpg imageFile: photo33711.jpg n 3 n 6 n 3 n 6 creationDate: 2010-10-16 HAS CREATOR creationDate: 2010-10-16 HAS CREATOR browserUsed: Firefox firstName: Jane browserUsed: Firefox firstName: Jane lastName: Murray lastName: Murray HAS CREATOR HAS CREATOR REPLY OF H K H N A n 2 A n 2 S O S K N W O S W C C S REPLY OF R R S S E W E W A n 5 O A n 5 O N T N T LIKES LIKES K O HAS CREATOR K O R R H A LIKES S C R E A T O S R E I K L n 1 n 8 n 1 n 4 n 7 LIKES REPLY OF LIKES REPLY OF firstName: Bryn creationDate: 2010-10-30 firstName: Bryn creationDate: 2010-10-30 creationDate: 2010-10-30 lastName: Davies browserUsed: { Firefox, Safari } lastName: Davies browserUsed: Firefox browserUsed: Safari imageFile: STRING? creationDate: STRING browserUsed: STRING ... Post KNOWS HAS CREATOR LIKES KNOWS firstName: STRING R lastName: STRING E P gender: STRING Person L Y birthday: DATE O LIKES F language: STRING? ... firstName: STRING imageFile: STRING? HAS CREATOR lastName: STRING creationDate: STRING H S A R E P L Y O F gender: STRING Person Message lastName: TIMESTAMP C R E A T birthday: DATE browserUsed: STRING O R LIKES ... locationIP: DATE Comment ... creationDate: STRING browserUsed: STRING ... REPLY OF 5/7
Prototype • Prototype system implemented in the regraph Python library (based on Neo4j PGs, see on GitHub https://github.com/Kappa-Dev/ReGraph ) • We convert rules + matchings to openCypher queries • regraph generalizes schema/data relation to hierarchies of graphs. regraph 6/7
Remarks Couple of technical issues: • no native support for node cloning and node merge (we wrote huge unreadable queries); • no way to set properties by dynamic keys (we use APOC). Pre-print available: Angela Bonifati (UCBL1), Peter Furniss (Neo4j), Alastair Green (Neo4j), Russ Harmer (CNRS), Eugenia Oshurko (ENSL), Hannes Voigt (Neo4j), Schema Validation and Evolution for Graph Databases , https://arxiv.org/abs/1902.06427 7/7
Recommend
More recommend