Buzzy Datamodel Overview
A comprehensive guide to understanding Buzzy's datamodel, including datatables, fields, relationships, and how to work with data programmatically.
What is the Buzzy Datamodel?
Buzzy has the ability to model complex data relationships, including 1:M (one-to-many) and N:M (many-to-many) relationships. This powerful datamodel allows you to build sophisticated applications without worrying about creating foreign keys or managing complex database schemasβit's all handled automatically.
Core Concepts
Datatable: A database table made up of fields. Each row in the datatable has multiple fields. Think of it as a structured way to store and organize your application's data.
Fields: Include basic types like text, number, date, as well as advanced relationship fields that connect datatables together.
Metadata: Every row automatically includes system-generated metadata:
_id
: Unique identifier, automatically generated for each rowembeddingRowID
: Foreign key from a "child" row to a "parent" row in another datatableauthor
: Name of the user who created the row (automatically populated)userID
: User ID of the user who created the row (automatically populated)viewers
: Field that stores a list of users who may view secured datateamViewers
: Field that stores a list of user teams who may view secured data
Understanding Relationships
1:M (One-to-Many) Relationships
A single parent record can have multiple child records. For example, one Invoice can have many Invoice Lines.
Invoice (Parent Datatable)
βββ _id: "inv_001"
βββ Invoice Number: "INV-2024-001"
βββ Customer: "Acme Corp"
βββ Invoice Lines (Sub-table field)
βββ Line 1
β βββ _id: "line_001"
β βββ embeddingRowID: "inv_001" β Links to parent Invoice
β βββ Description: "Web Development"
β βββ Amount: 1500
βββ Line 2
βββ _id: "line_002"
βββ embeddingRowID: "inv_001" β Links to parent Invoice
βββ Description: "Design Services"
βββ Amount: 800
How to set up: In the Invoice datatable, add a Sub-table field pointing to the Invoice Lines datatable. Buzzy automatically manages the embeddingRowID
relationships.
N:M (Many-to-Many) Relationships
Multiple records from one datatable can relate to multiple records in another datatable. For example, Invoice Lines can reference Products, where each Product can appear in many invoice lines.
Invoice Lines ββ Products (Many-to-Many via Linked Table Field)
Invoice Line 1
βββ _id: "line_001"
βββ embeddingRowID: "inv_001"
βββ Quantity: 2
βββ Product (Linked Table Field): "prod_123" β References Product datatable
Invoice Line 2
βββ _id: "line_002"
βββ embeddingRowID: "inv_001"
βββ Quantity: 1
βββ Product (Linked Table Field): "prod_456" β References Product datatable
Product "prod_123"
βββ _id: "prod_123"
βββ Name: "Premium Widget"
βββ Price: 99.99
βββ Category: "Electronics"
Product "prod_456"
βββ _id: "prod_456"
βββ Name: "Standard Widget"
βββ Price: 49.99
βββ Category: "Electronics"
How to set up: In the Invoice Lines datatable, add a Linked Table Field to the Products datatable.
Multi-Level Relationships
You can create complex hierarchies by combining 1:M and N:M relationships:
Organization (Level 1)
βββ _id: "org_001"
βββ Name: "Tech Solutions Inc"
βββ Invoices (Sub-table)
βββ Invoice 1
β βββ _id: "inv_001"
β βββ embeddingRowID: "org_001"
β βββ Invoice Lines (Sub-table)
β βββ Line 1 β Product A (Linked Table Field)
β βββ Line 2 β Product B (Linked Table Field)
βββ Invoice 2
βββ _id: "inv_002"
βββ embeddingRowID: "org_001"
βββ Invoice Lines (Sub-table)
βββ Line 1 β Product C (Linked Table Field)
Practical Examples
Example 1: Chat Application (Simple 1:M)
Based on our AI-Powered Chat App example:
Chat (Parent)
βββ _id: "chat_001"
βββ Title: "Project Discussion"
βββ Messages (Sub-table)
βββ Message 1
β βββ _id: "msg_001"
β βββ embeddingRowID: "chat_001"
β βββ Content: "Let's discuss the project timeline"
β βββ Author: "[email protected]"
βββ Message 2
βββ _id: "msg_002"
βββ embeddingRowID: "chat_001"
βββ Content: "Sounds good, when can we start?"
βββ Author: "[email protected]"
Example 2: Project Management (Complex Relationships)
Projects
βββ _id: "proj_001"
βββ Name: "Website Redesign"
βββ Tasks (Sub-table)
βββ Task 1
β βββ _id: "task_001"
β βββ embeddingRowID: "proj_001"
β βββ Title: "Design Homepage"
β βββ Assignee (Linked Table Field): "user_123"
β βββ Status: "In Progress"
βββ Task 2
βββ _id: "task_002"
βββ embeddingRowID: "proj_001"
βββ Title: "Develop Contact Form"
βββ Assignee (Linked Table Field): "user_456"
βββ Status: "Not Started"
Users (Referenced by Tasks)
βββ User 1
β βββ _id: "user_123"
β βββ Name: "Alice Designer"
β βββ Role: "Designer"
βββ User 2
βββ _id: "user_456"
βββ Name: "Bob Developer"
βββ Role: "Developer"
Displaying Related Data
When you display data in Buzzy, you can automatically show related information:
Child data: Include a sub-table field on a screen to show all related child records
Linked data: Add fields from linked datatables to display related information
Parent data: Reference parent, grandparent, or great-grandparent fields for breadcrumb navigation
For example, when displaying an Invoice Line, you can show:
The Invoice Number (from parent Invoice)
The Organization Name (from grandparent Organization)
The Product Name and Price (from linked Product datatable)
Working with Data Programmatically
Buzzy provides comprehensive APIs for working with your datamodel programmatically. For detailed examples and implementation guides, see:
REST API Documentation - Full CRUD operations for external integrations
Async API Documentation - Client-side data operations within Code Widgets
Security and Access Control
Buzzy's datamodel includes sophisticated security features:
Viewers Field: Control who can see specific records
Team Viewers Field: Combine team-based and user-based access
Organizations Pattern: Multi-tenant SaaS security model
Personal Data Pattern: User-specific data access
Performance Considerations
When designing your datamodel:
Limit nesting levels: While you can create multiple levels of relationships, test for performance with your expected data volumes
Use filtering: Apply filters to sub-tables and views to limit data retrieval
Consider indexing: For large datasets, consider how your queries will perform
Upgrade infrastructure: For high-performance needs, consider upgrading your Buzzy deployment
Best Practices
Plan your relationships: Sketch out your datamodel before implementation
Use consistent naming: Follow clear naming conventions for datatables and fields
Test with real data: Verify performance with realistic data volumes
Document your model: Keep track of relationships for team members
Start simple: Begin with basic relationships and add complexity as needed
Related Documentation
This documentation provides a comprehensive overview of Buzzy's datamodel capabilities. For specific implementation details, refer to the linked documentation sections above.
Last updated