HACKER Q&A
📣 TekMol

Should I switch away from SQLite if I only use JSON fields?


I noticed that in 2024 I completely stopped using database tables with more than one column. Everything just goes into one single JSON column, which I always call "data".

So to query all entries from the table "cars", I do:

    SELECT * FROM cars
    WHERE data ->> '$.color' = 'blue';
That seems a bit redundant, considering all my tables have just the data column. So if the DB knew this, the query could be just

    SELECT * FROM cars
    WHERE color = 'blue';
Should I start looking for a database that works like this? Are there any databases like this out there? It would have to be a database that stores the data in a single file like SQLite. Because I would not want to give up that convenience.


  👤 pavel_lishin Accepted Answer ✓
> I noticed that in 2024 I completely stopped using database tables with more than one column. Everything just goes into one single JSON column, which I always call "data".

Inquiring minds want to know: why?


👤 karimfromjordan
SQLite doesn't support indexing JSON (yet) unless you use generated columns. So performance-wise SQLite would probably not be the best option if that's all you do.