A walkthrough of implementing a DCB (Dynamic Consistency Boundary)-compliant Event Store using SQLite with just a four-column table and a conditional INSERT. The approach maps each DCB specification requirement to a SQL construct: event type and tag filtering via JSON_EXTRACT, sequence positions via AUTOINCREMENT, and optimistic locking via a conditional INSERT...SELECT...WHERE that re-runs the read query to verify no conflicting events were appended concurrently. The technique works safely in SQLite due to its file-level lock, and the appendix explains how to adapt it for PostgreSQL/MySQL using SERIALIZABLE transaction isolation. The implementation is used by the open-source PHP Backslash Event Sourcing library.
Table of contents
The READ Requirements #The WRITE Requirements #Conclusion #Appendix: A Note on MariaDB, MySQL, and PostgreSQL #Sort: