No Code in the Database... Right?

"No code in the database" is a mantra instilled in developers from computer science school onward. It's a fundamental principle of traditional database design aimed at separation of concerns and maintainability.

But what if your database IS your code? What if the data store not only saves your state but actively manages your business logic, acts as your API, and functions as your message bus?

The Traditional Problem: Framework Ownership

When you start a project using a traditional SQL database, frameworks like Django, Laravel, or Rails become the central authority.

These frameworks effectively "own" the database. They manage the schema through migrations and use an Object-Relational Mapping (ORM) layer to perform queries. This is why mixing major frameworks that touch the same core data is heavily discouraged—each framework wants to be the single source of truth for the database schema and application logic.

The ThingsDB Shift: The Database as the Hub

With a database like ThingsDB, the model fundamentally changes. Here, the database is your runtime environment, blurring the line between data storage and application logic.

This architecture is especially powerful if your project involves:

  • Polyglot Microservices: Using many different components or services, possibly written in different programming languages.

  • Decentralized Access: Needing all components to access the same, unified data source and logic hub.

ThingsDB steps into the role of the Data API and Message Bus, centralizing data management and coordination.

Guaranteeing Data State and Event-Driven Architecture

This integrated approach offers powerful mechanisms to guarantee data integrity and build truly reactive applications:

  1. Strict Data Integrity with Typed Collections and Procedures: By defining procedures with strict input restrictions and leveraging fully typed collections, you guarantee the validity and consistent state of your data. The data cannot be modified in an inconsistent way because the logic lives right alongside it.

  2. No More Polling with Rooms and Events: ThingsDB removes the need for wasteful polling across your services. Instead, you build truly event-driven applications using Rooms and Events. When data changes, all subscribing components are immediately notified, allowing your application to react instantly.

In short, while frameworks like Django and Laravel are perfect for applications where they serve as the central brain, ThingsDB enables a modern, event-driven architecture where the database is a powerful, active participant in your business logic, simplifying communication and guaranteeing data consistency across diverse application components. Choose the tool that best aligns with your project's long-term complexity and inter-service communication needs.

Next
Next

Event-Driven Updates with ThingsDB