Understanding Bubble's Unique Database Structure

Why unlearning old habits might be the key to unlocking Bubble's potential.

Dec 20, 2024

For developers transitioning from traditional coding to Bubble, its database structure can feel like stepping into a parallel universe. Beneath the surface, it’s built on PostgreSQL, but in practice, it functions entirely differently. Traditional concepts like primary keys, foreign keys, and SQL joins are nowhere to be seen. Instead, Bubble offers a uniquely abstracted and intuitive system, perfect for rapidly building applications—but it requires a shift in mindset.

When I first started working with Bubble, I had to let go of some old habits and embrace a new way of thinking. Here’s what I’ve learned along the way and how you can adjust to harness Bubble’s power effectively:

1. Let Go of Primary and Foreign Keys

In conventional relational databases, primary and foreign keys are the backbone of managing relationships between tables. Bubble, however, takes a radically different approach.

Bubble’s Approach:

  • Each "Thing" (Bubble’s term for a database object) is automatically assigned a unique ID. But unlike traditional databases, you won’t interact with this ID directly.

  • When you reference one Thing from another, you’re storing the entire Thing—not just its ID.

Why it Matters:
By abstracting away primary and foreign keys, Bubble allows you to focus on functionality and business logic rather than managing IDs or joins. This approach simplifies workflows, making it faster to build and iterate.

2. Embrace the Simplicity of Minimal IDs

Traditional development often involves manually managing unique IDs for data relationships. Bubble renders this unnecessary.

Bubble’s Approach:

  • When linking data types—say, connecting a User to an Order—you store the actual User Thing in the Order, not the User’s ID.

Why it Matters:
This eliminates the need for repetitive lookups or joins and makes the data structure easier to understand and navigate. Bubble handles the behind-the-scenes complexity so you can stay focused on building features.

3. Forget SQL Joins: Meet Virtual Joins

SQL developers often live and breathe joins, connecting tables with queries to extract related data. In Bubble, that’s a thing of the past.

Bubble’s Approach:

  • Bubble uses "virtual joins" by allowing you to reference one Thing within another. Instead of querying multiple tables, you traverse the data structure directly.

Why it Matters:
This shift in approach minimizes database searches, significantly improving app performance. New Bubble developers sometimes fall into the trap of performing multiple searches when referencing data—understanding virtual joins is key to avoiding these inefficiencies.

4. Rethink One-to-Many Relationships

In traditional databases, you’d create join tables for one-to-many or many-to-many relationships. Bubble simplifies this with lists.

Bubble’s Approach:

  • Want to associate Tasks with a Project? Simply store a list of Tasks directly within the Project Thing.

Why it Matters:
This design eliminates the need for extra tables, reducing complexity while making related data easy to query and manage.

Final Thought:

Bubble’s database system strips away much of the complexity of traditional databases, letting you focus on what really matters—building your application. For developers with a traditional background, it’s less about learning something new and more about unlearning old habits.

By adapting to Bubble’s abstractions, you unlock a faster way to iterate and test new ideas. It’s not just a shift in technology; it’s a shift in mindset that paves the way for rapid innovation.

Orzo Blue


Bringing your ideas to life

Location

Brighton, United Kingdom

Telephone

+44 (0) 1273 921909