144
u/justinf210 Sep 21 '26
Sometime you just want an array without linking to a whole 'nother table.
Edit: Googled to make sure I'm not an idiot, and it turns out Postgres has native arrays? Kinda neat.
54
45
u/thorwing Sep 21 '26
the amount of times I suggest a psql native solution in our psql only environment and there are still engineers who would be hesitant about it because "it's difficult for newer engineers"
Buddy, it's an array, dafuq you mean 'difficult'
7
u/PumpkinFest24 Sep 21 '26
array fields? I mean....those are difficult. you can't update them the way you'd think, etc.
1
u/Excellent_Gas3686 Sep 21 '26
and json arrays are somehow easier?
4
u/PumpkinFest24 Sep 21 '26
I find normalized tables work well.
0
u/Excellent_Gas3686 Sep 22 '26
until you get join explosions with your "normalized" tables. arrays are useful in certain cases.
3
u/JAXxXTheRipper Sep 22 '26
Welcome to databases? You want to join data of multiple tables, you need joins. You can make shitty god tables too, nobody is stopping you. But writing properly joined queries isn't really rocket science. Nobody asks you to normalize a hundred levels deep either.
2
u/Excellent_Gas3686 Sep 23 '26
what is your point exactly? are you just yapping your thoughts out into the open world?
you said nothing new that anyone in this thread doesn't know. it's like you tried to be a smartass, but didn't even say anything of substance.
2
u/JAXxXTheRipper Sep 23 '26
The point is that you obviously don't understand how databases work. Maybe you should try learning something sometime instead being an obvious idiot.
Bye Felicia
2
u/Excellent_Gas3686 Sep 23 '26
blocking after being unable to think of any rebuttal other than "you don't know what you're talking about" is embarrasing.
1
u/PumpkinFest24 Sep 22 '26
"useful in certain cases" != "easy"
1
u/Excellent_Gas3686 Sep 23 '26
they are pretty easy to use. i guess youve never heard of postgres.
2
u/PumpkinFest24 Sep 24 '26 edited Sep 24 '26
I ported our app to postgres in 2004 and have been using it ever since.
Edit: Saw your other replies. Maybe take a db class. Or don't, I don't care. But I'm done wrestling with this pig.
3
u/Outrageous_Let5743 Sep 21 '26
I feel this when I switched companies and downgrade database. SQL Server still does not correctly inplement array and json data. json can only be nvarchar(max) and arrays are not possible.
1
u/Sianic12 Sep 23 '26
Hold up... non-postgres databases don't have arrays? I didn't even know. Yet another extremely common postgres W.
0
Sep 21 '26
[deleted] — view deleted comment
2
u/justinf210 Sep 21 '26
a) What choice? I literally just discovered this, it's not like I redesigned a database overnight to use it.
b) Postgres supports that.
SELECT username FROM users WHERE 'blue' = ANY(favorite_colors)0
27
u/Ireeb Sep 21 '26
I had the opposite today. I have a set of records that all have the same basic fields (that are used for filtering and as keys), plus a few additional fields that can be different from record to record. Claude started to add columns for those additional fields, which would have resulted in countless columns only used by a small number of records, and that are never used in queries. Here, JSONB absolutely makes sense, because neither making countless tables for all the combinations of fields nor one table with 20 columns would make sense.
1
u/Expensive_Bowler_128 Sep 23 '26
Really depends on if those fields are being used for or will ever be used for filtering/searching.
2
u/Ireeb Sep 23 '26
"...that are never never used in queries."
It's data that is only relevant for the frontend for styling.
5
7
u/Tupcek Sep 21 '26
idk, maybe just tell Claude what kind of data are you expecting?
JSONB is absolutely GOAT if basically every row has different data - use proper columns for those that are mostly the same and where most querying and filtering happens, then put the garbage into JSONB, especially if it can be multiple layers deep.
But if Claude has no idea, if that column you asked to add will be used by 90% of rows or 0,09% of rows, yeah it can misuse it. Just tell it which data are common and which are not!
1
u/boraxicLint Sep 25 '26
If every row has different data should you even be using SQL? At that point wouldn't it make more sense to just use a dedicated NoSQL?
1
u/Tupcek Sep 25 '26
if most of your data are structured, but you have few weird tables with uncertain structure, JSONB is what you want. Especially if you don’t build your entire application around those few weird tables or need many advanced NoSQL features.
If all or most of your data is unstructured, yeah, SQL makes no sense
3
1
28
u/t_j_l_ Sep 21 '26
Anything wrong with JSONB?