Jesus died at 33, so that can’t get returned in the query response lol
SELECT user FROM db WHERE age BETWEEN 25 AND 35;
Fuck your mongo
We just got a ticket in, our users need several new fields in the user table
Relational virgin:
NNNNNOOOOOO I’ll need this sprint to modify the user table and write the etl script
NoSQL Chad:
private String newField1;
private boolean newField2;
private Object newField3;
//And now, I close the ticket and go get lunch beers.
All this talk about query format and no one discussing the dogshit database design requiring the record to be updated whenever the user has a birthday? Store the day of birth and do the math at query time at least!
I’m no mongo fan, but this is ragebait.
You can write it like this, but you can also write {age: {$gte: 25, $lt: 30}}
If you’re going to dunk on mongo, let’s talk about how db.collection.update() replaces the whole record by default instead of updating keys
Thanks for letting me know that if I’m ever asked if I’m willing to learn mongo the answer is no.
I do believe Mongo has some valid niche use cases, but far, far too many people think it’s just a no-worries way to dump objects into a database without having to deal with all that fussy schema stuff. They only realize their mistake when it comes time to actually use that data as anything other than a huge, unmanageable blob of nested fields.
Granted, Mongo’s marketing kind of encourages this.
Slightly off-topic: I get so confused with age conventions. I’m self-taught and do some ad-hoc work for the organization I work for (where no one else has any interest).
To get users between 25 and 30, wouldn’t you want strictly less than 30? And greater than or equal to 25? Or for age is it inclusive?
Realistically you wouldn’t store age, you’d store birthdate or possibly a datetime value, and calculate it from there
First Normal Form users unite!
By the by, as someone who have used both NoSQL and SQL extensively (once in the same project), the trick of NoSQL is that you shouldn’t use FNF and compute that at write time. The idea is that it’s faster to MapReduce pre calculated values since that’s the operation you want to optimize in a NoSQL world. A lot of people get that wrong and just replace MySQL with Mongo without rethinking usage and schemas.
But even in a NoSQL context I’d rather use a Postgres jsonb column over MongoDB.
Why strictly less than 30 and greater or equal 25? (25 ≤ X < 30)
Shouldnt it be strictly less and strictly more (25 < X < 30)?
Well if you’re 25 and a day, that would mean you wouldn’t be able to fit any definition. The second after you turn 25 you would be “over 25” and could be included in 25, over 25 and between 25 and X until you turn 26 and the same repeats.
Even if you’re 25 and 11 months, you should still be counted as 25. Same way it should be for other age based restrictions