C
C#3y ago
Alex

When to use Databases vs Filesystem Storage

I have a question about the title: I've gone around the internet looking for answers in this, but I haven't found a concrete one. I understand that Filesystem Storage is supposed to be "temporary", as in saving files to the client, and a database is supposed to be permament, storing the files in the database hosted in a server, and having everything go through software in the server that accesses the database and brings back a response. But why should it be done this way, and instead, why can't the stuff be stored in the server's filesystem storage, permanently? It seems simpler, and the answer can't just be "due to performance and speed", can it?
6 Replies
Pobiega
Pobiega3y ago
For one, when running in the cloud the "filesystem" doesnt really exist at all. Outside of the cloud, its still not ideal for data, but might be a decent enough place for actual uploaded files searching for a file on disk is a very slow process, while searching in a database is very fast
Alex
AlexOP3y ago
But doesn't the database have to store its files on the filesystem at some point?
Pobiega
Pobiega3y ago
on a filesystem in the cloud, thats an entirely different system and even locally, you'd take care to back up those particular files
Becquerel
Becquerel3y ago
You absolutely can just store everything on the filesystem you lose something in performance, and probably maintainability, but for personal apps the speed difference is not important and you gain a lot of simplicity by not interacting with a database (depending on how much data you're actually saving) spooling up a database instance to store the equivalent of 20 lines of JSON would be incredibly pointless
Alex
AlexOP3y ago
Huh, but isn't the database just the software that stores stuff on its storage afterwards? I l thought the place they stored them in would be in the files, as in, the file system used So if it can be used on the cloud... How does it work there? Unless they save it in themselves, like their database file. Is that it? So the database is a feature rich filesystem, similarly to how NTFS is a filesys? And then there's probably software to interact w it
Becquerel
Becquerel3y ago
database is a concept there are various kinds of database and various implementations of databases such as SQL server, MySQL, postgres databases are different from filesystems because they don't organise information in files and directories traditional databases ('relational') ones structure data in rows and tables, lime an excel spreadsheet some newer kinds ('nosql' or 'document') are more unstructured how databases persist that information is up to them. they can choose to store it via the filesystem but don't have to redis, for example, is a database that only stored things in memory
Want results from more Discord servers?
Add your server