A Database Table Is Not a Business Object
You have a Customers table. Do you have a Customer?
You have a SalesOrder table. Do you have a Sales Order?
If your answer is "yes, because that is where they are stored," you have treated two different things as one. Even experienced developers make this mistake.
A table stores data. A business object also defines what can be done with that data.
The difference becomes clear when the application needs to do more than update a record.
What Does a Table Describe?
A table describes the structure of its data. It has columns with specific types, keys, and relationships with other tables. The database can enforce constraints and protect data integrity.
The SalesOrder table may have a Status field. It may also record who changed the order, along with the reason for the change.
Those fields alone, however, do not define the order’s behavior. Status stores a value. Someone still needs to define who may change it and under what conditions.
Even if some of this behavior is implemented in the database, it remains a separate responsibility from storage.
The problem begins when we assume that designing the table means we have also defined the Sales Order.
What Is a Business Object?
A business object represents something with a specific meaning in the operation of a business. A Sales Order is one such object. The application needs to understand its behavior as well as its data structure.
This does not mean everything must fit inside a single SalesOrder class. It means the order needs a clear, consistent definition, regardless of which part of the application uses it.
Let us look at what that definition includes. We will use a Sales Order as our example, but similar concerns apply to other business documents, such as Invoices and Delivery Notes.
1. It Has Identity
An order remains the same order even if its delivery address changes or a line is added.
An internal ID = 1042 allows the system to identify it. People may use an order number, perhaps together with a document series or year. These ways of identifying the order are related, but they serve different needs.
Identity allows us to refer to the same order throughout its life, despite changes to its data.
2. It Has State
An order may start as a Draft and require approval before it can be fulfilled. Its exact lifecycle depends on how the business operates.
The allowed transitions need to be defined. In a particular system, for example, canceling an order that has already been invoiced may require a reversal process first.
That restriction is part of the order’s behavior. It must apply whether cancellation is requested through a form or through an API.
If each entry point makes its own decisions about what is allowed, the application ends up with different versions of the same Sales Order.
3. It Has Rules
Can a user change the price after approval? Can a line be added after shipping has started?
The answers come from how the business operates. The database schema alone cannot provide them.
The UI may ask the application whether an action is allowed so it can give the user immediate feedback. When executing the action, the application must check and enforce the applicable business rules, regardless of any earlier check requested by the UI. Disabling a button does not protect against a request coming from elsewhere.
What matters is having one authoritative definition of the rule. Independent implementations of the same rule can easily drift apart over time.
4. It Has Actions
An order is not limited to Insert, Update, and Delete.
A user asks to approve or cancel it. They may also ask to create a Delivery Note from it.
Approval will probably cause database updates. But the word "update" does not explain what that action means to the business.
The Approve action has specific preconditions and outcomes. It includes checking the user’s authority and should record who took responsibility for the approval.
The action’s name expresses the intent. The database updates implement its result.
5. It Has History
An order’s current state does not necessarily explain how it reached that state.
If a quantity changes from ten units to six, the latest value does not tell us whether the customer requested the change or there was an availability problem.
The required history depends on the business. Not every field change needs the same treatment. Approval of a business document, however, may require an explicit record because it assigns responsibility and allows a process to continue.
The application needs a deliberate policy about which parts of the order’s past it preserves. Otherwise, when a dispute arises, it may have only the latest stored snapshot.
6. It Has Meaningful Relationships
An order has lines. That relationship means more than being able to join two tables.
A line belongs to a particular order and contributes to its totals. Changing its quantity may affect the total amount.
If a draft order can be deleted, the application needs to define what happens to its lines. An approved order may follow a different rule.
Foreign keys help preserve the integrity of these relationships. Their business meaning also needs to be expressed in the application’s behavior.
Why CRUD Is Not Enough
CRUD describes basic data management operations. It is essential in many applications, but it does not fully describe the user’s work.
"Save this change" leaves open the question of whether the change is allowed. The application must answer that before carrying it out.
Without a consistent definition of the Sales Order, those decisions become scattered:
- A check in the form decides whether to enable a button.
- A separate check in the API decides whether to allow the action.
- A stored procedure applies its own version of the restriction.
- A bulk update process bypasses some of those checks.
This arrangement may work for a long time. The problem becomes visible when a rule changes and only some parts of the application are updated.
The same action is then allowed through one path and rejected through another. The maintenance problem now has a specific cause. The business model is fragmented, and its implementations have started to disagree.
An Example
Consider creating a Delivery Note from a Sales Order.
From a storage perspective, new records will be created. Some values will come from the order.
For the business, however, this is a document transformation. The application needs to determine exactly what will be transferred to the new Delivery Note.
The order may be for ten units, while the first shipment contains only six. The remaining units stay outstanding. A later shipment must account for what has already been fulfilled.
The Delivery Note needs a link to the source order at a level that supports quantity tracking. If it is canceled, the effect on the order’s fulfillment must be defined.
Depending on the system, the action may also update inventory. That consequence must be part of the process definition.
An insert is one implementation step. The CreateDeliveryNote action expresses the work that needs to be completed consistently.
What to Take Away
The storage structure describes how we keep the data.
The business model describes what the data means and what we are allowed to do with it.
When designing an application, it is worth examining the things the business works with before finalizing the tables.
Take a Sales Order and follow it from creation to completion. The questions that arise will lead to decisions that a table diagram alone cannot express.
The database schema will need to support those decisions. Its existence does not replace them.
Keep this in mind:
Do not confuse the table with the object.
Top comments (0)