Database expert runs Doom in SQL with 5900 lines of code
Running Doom in SQL: How a Database Revolutionized a Classic Hack
For years, the classic 1993 game Doom has reigned supreme in the world of software hacking and gaming. But in the digital landscape of 2026, this legendary title has found a surprisingly new home: the world of relational databases. Enter SQLDoom, an ambitious project that tackles the idea of running a high-octane shooter not just anywhere under the sun, but inside a highly structured database environment.
The core innovation of SQLDoom lies in treating the game’s architecture as a set of interconnected tables. Instead of traditional code handling every interaction, the entire gameplay logic is managed by a powerful relational database, specifically the performance-focused, Postgres-compatible CedarDB. This setup proves that when you think like a database architect, you can redefine how complex systems are built.
How does this magic happen? While the visual spectacle, sound, and player inputs are handled by a separate Python frontend—acting much like the peripheral hardware of a standard PC—the heavy lifting, the mathematics, and the internal state of the game reside entirely within the database. This division of labor allows the system to operate with incredible efficiency.
The transformation of the original game into a database structure was surprisingly straightforward. The entities within the Doom package file were inherently relational, structured in parent-child relationships that translated seamlessly into plain SQL tables. This simple conversion reduced the complex structure of the game entities into database rows, making data management intuitive.
Perhaps the most dazzling result of this approach was the sheer efficiency gain. The project demonstrated that querying the game logic was far more efficient than iterating through standard programming loops. By leveraging SQL’s native capabilities, complex updates—such as changing weapon characteristics or enemy behavior on-the-fly—could be executed in a single statement, dramatically simplifying the development process.
The graphical renderer, while trickier, also benefits from this relational approach. The system uses queries spanning up to 89 tables to manage the visual pipeline, demonstrating how concepts like Carmack’s Binary Space Partitioning can be cleverly represented through simple SELECT and ORDER BY commands.
Furthermore, the database framework provides a massive advantage when tackling multiplayer functionality. Maintaining synchronized states across multiple entities with copious dependencies is precisely what databases are designed to handle. By utilizing transaction management, the system ensures that all synced states are maintained perfectly and instantly, effectively handling snapshots and access control with minimal effort.
SQLDoom stands as a vibrant testament to the power of database architecture, showing that ancient game concepts can be modernized with cutting-edge data management techniques. For those interested in pushing the boundaries of software, this project is an engaging exploration of how structured data can bring a classic icon to thrilling, hyper-efficient life.
You can find more details and the project yourself on the GitHub repository or read the fascinating details on the project’s blog.