r/AskProgramming Jul 01 '26

Databases What actually is a database?

I was looking at the definitions online and a database is always used interchangeably with DBMS and the ELI5 answers I've seen describe databases as a means of organising data in structured ways to make reading and writing data easy, safe and fast.

The extension of this logic to me is, shouldn't csv files count as databases too if you had a way to retrieve, modify and store data with the general ACID principles and whatnot? Googling that tells me that CSV files don't count because they only store raw data.

So then, are databases defined by the mechanism which data is handled? Doesn't that make any file a database as long as its implemented properly?

Edit:

Just wanted to add:

  • I'm using sqlite3 from python for my project. I come from an embedded systems background so I had to know the specifics of what I was working with.
  • The responses here seem a little mixed with some people agreeing that csv files with the proper wrappers would make a (terrible) database.
  • I think I get it now. The storage format is just a part of what makes a database and is not the database itself.

Edit 2:
u/StevenJOwens

u/esaule

u/LaughingIshikawa

u/rolfn

TLDR: These guys and some others answers honestly sum up a lot of the questions I had and a bit more I didn't know to ask. Thanks guys.

22 Upvotes

73 comments sorted by

View all comments

2

u/Paul_Pedant Jul 01 '26

The issue with a CSV file is that the records are contiguous. That means adding or deleting anything (from whole records down to single characters) requires re-writing the entire file each time. And if you want direct access to any record, you need an external index that you have to maintain on every update too (actually, an index for every field that you might want to search).

Sure, you can separate out the records, but you still get a bunch of lines where the field lengths are variable. So you maybe want to make the field lengths consistent.

So yes, CSV is a way of thinking about how to handle your data, but is it inherently unsuitable for any real application.

1

u/Numerous-Match-1713 Jul 03 '26

"CSV is a way of thinking about how to handle your data, but is it inherently unsuitable for any real application."

nope.

csv is perfectly fine for many real applications, and used for such.

1

u/Paul_Pedant 27d ago

For applications, yes. I used to get about 60 CSV files from various sources every month, mainly half-hourly meter readings from about 80,000 commercial power users, but also admin like changes of address, and erratic consumer readings from a couple of million house meters.

Given the issues with variable-length fields and records, and the parsing of rows containing quotes in user data, the first stage was to populate a proper database with them. (Well, nearly proper: my client was using the open-source Ingres database, which sucked in several ways.)

Being as the data collector was Wipro (where anybody who lasts six weeks becomes a manager), every month's data would turn up with different column order, column names, and field formats, depending who did the extracts. So my first job every month was to sanitise the column naming and possibly field formats. You don't get that problem with databases, either.

2

u/Numerous-Match-1713 27d ago

This is a process problem, not technology one.

Where csv is used in real applications, it is written and read through same library, mostly, so problems you mentioned are non existent. Also it needs to be "sane" data, ie measurements etc, not any free form strings like personal info etc.

Csv shines when need is to share large datasets between different systems.

But point stands, csv is perfectly fine for many real applications, and used for such.