Beyond SQL Joins: Exploring SurrealDB's Multi-Model Relationships
Blog post from SurrealDB
SurrealDB, a multi-model database, offers alternative ways to join data without traditional SQL joins by leveraging document and graph data models. The database supports three primary methods for creating relationships: embedded records, record links, and graph relations. Embedded records allow for denormalization by storing complete information within a single record, enhancing query speed at the expense of increased storage usage. Record links facilitate normalized data models using record IDs to link records, eliminating the complexity of traditional joins and enabling direct record fetching. Graph relations introduce a "relate" statement for establishing graph-based connections, allowing for more flexible and powerful data querying. This method simplifies complex queries and enables bi-directional data traversal by defining relationships at write time, streamlining query processes. Despite trade-offs, SurrealDB's approach simplifies the creation of complex data relationships and enhances query efficiency, distinguishing it from traditional and graph-only databases.