HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Separate table for 'scheduled payments' and 'completed payments'?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
separateforcompletedandpaymentstablescheduled

Problem

In a previous financial payments related database I'd worked on, it just had one large transactions table. We would insert scheduled transactions for the future, and when that time came, we'd execute them, and update that row to status completed.

I've kept wondering why they didn't have a separate 'completed transactions' table? Is that bad practice?

Solution

There is one entity - financial transaction, that can be in a various states. Completed, scheduled, postponed, rolled back etc. State is the property of the entity, only part of the whole, like the field is a part of the row.

When the state is just a field of the table it is possible to create DB structure and code that are invariant regardless of how many states are possible. In the opposite case each new state produce the new table and lot of code should be rewritten to reflect the changes.

Context

StackExchange Database Administrators Q#76804, answer score: 4

Revisions (0)

No revisions yet.