
ALT Databases are for storing global variables. We usually call them “rows” or “records” instead, but they’re definitionally global variables: any part of your program can read or write them. Isn’t this kind of weird? It’s common programming advice that global variables are bad, and yet many elegant programs rely on databases. Either the common advice is wrong, or there’s something special about databases that makes them the exception to the rule. What’s so bad about global variables? Here’s the two main reasons, in my view: They allow any part of your program to implicitly send data to any other part instead of passing it around via function signatures They couple different parts of your program: if one part depends on a variable having some value, any other part can break it

ALT Both of these apply to databases. Any part of your program that makes a query can send and receive data from any other part of your program. In practice this happens all the time: one function will save some data on a record, and another one will check for it. And if you haven’t seen bugs where some piece of code makes some incorrect expectation about the shape of a database column, you haven’t been working on web systems for long enough. So why aren’t database-backed apps in terrible architectural shape? In the rest of this post I’ll consider some options.





















![[🍃마이동풍맛 막가렁]르세 (@Rse_ute_ruri) profile picture](https://pbs.twimg.com/profile_images/1513430614221144070/dZtWSu4M_400x400.png)




















