Ashutosh Bapat: DBaaG with SQL/PGQ

For those who have studied ERD-lore, it's not new that a relational database is very much like a graph. But it has taken SQL, more than 30 years since it became a standard and almost half a century since its inception to incorporate construct that will allow a DataBase to be treated as a Graph, DBaaG. This is surprising given that SQL was developed as language for relational databases which are modeled using ER diagrams. Better late than never. SQL/PGQ has arrived as 16th part of SQL:2023. Entity Relationship Diagram, ERD in short, is a tool to model and visualize a database as entity types (which classify the things of interest) and relationships that can exist between them. Entity types and the relationships both map to relations in a Relational DataBase Management System (RDBMS in short). The rows in the relations represent entities (instances of entity types) and relationship between entities respectively. Fig. 1 below shows an ERD for a hypothetical shop. This diagram very much looks like a graph with entity types represented as nodes and relationships represented by edges. That's exactly what SQL/PGQ is about. It adds language constructs to SQL to present underlying database as a "Property Graph". For example, property graph definition corresponding to the above ERD would look like CREATE PROPERTY GRAPH shop VERTEX TABLES (     CreditCard label Payment,     BankAccount label Payment,     Person label Customer,     Company label Customer,     Trust label Customer,     Wishlist label ProdLink,     Order label ProdLink,     Product) EDGE TABLES (     CCOwns label Owns     BAHolds lable Owns,     CustOrders label CustLink,     CustWishlist label CustLink,     CompanyOrders label CustLink,     CompanyWishlist label CustLink,     TrustOrders label CustLink,     TrustWishlist label CustLink,     OrderCCPayment label OrderPayment,     OrderBAPayment label OrderPayment,     OrderItems label ItemLink,     Wishl[...]

sql
相关推荐 去reddit讨论