Most business data is begging for a (bi)temporal, immutable, event based model. Why don’t we default to that?
Press enter or click to view image in full size
Many web programming projects and features start out with modelling the data in a CRUD (Create, Read, Update, Delete) model. It’s the default thing in Rails or Django style frameworks and ORMs. It’s what they teach at SQL courses. You have a table of “Things” and then you do INSERT, SELECT, UPDATE, DELETE queries. It’s easy and it works. Until someone asks you how many Things you had last week in state “foo”, including those that were deleted or changed state since then.
Example: The Trading Company
Let’s start with an example. Joe decides to start an ecommerce company callend The Trading Company and as a first line of business, he creates an Order table with some simple state machine. Let’s omit bunch of things like billing, shipping, products and money for now. Joe fires up a web framework that produces the first database table: