4 ms·
Read the original relational database paper by Codd. The problem is that trees of data are not flexible for querying, you really need a graph. If you draw it ou
by bsdpufferfish 3y ago
Read the original relational database paper by Codd. The problem is that trees of data are not flexible for querying, you really need a graph. If you draw it out on paper, you will find a relation is a very efficient way to store general graphs. I'm actually suprised to hear this from a C++ engineer, because sorting and searching columns of data is the name of the game in C++.
Another key problem they solve is separating the logical representation from the on disk representation. You can evolve and and optimize storage without breaking anything.
The other problem with files is that you have a disconnect between in memory and on disk. You have to constantly serialize and deserialize. Sqlite has quite a bit of info on this: https://www.sqlite.org/appfileformat.html https://www.sqlite.org/appfileformat.html
- bun_terminator 3y agoBut that's the thing: All that is nice on paper. Of course the relational nature is nice. Of course the disk representation is nice. But I never feel like that's worth the trouble day in day out. The costs, the mystery box of performance, the insane statements, the extra hardware, the updates, the strange data types, the box of tricks everyone needs to make them behave. But I've been made aware that our usecases suck, so I'll attribute most to that.
- hobs 3y agoThe problems are not specific to SQL though - if you want to store and manage huge amounts of data you're going to need some specialized data structures, some way to manage disks paging and memory, manage consistency, isolation, durability, and atomicity of your changes. The general idea is that its such a PITA to deal with all that so just let a database do it, and of course the consequence is an often leaky abstraction because computers suck.
- dgsb 3y agoIt's more than a PITA, it's almost impossible to implement ACID correctly. It's very very hard to do. There almost no point in implementing that in house when we have sqlite3.