News for hackers. Stuff that matters.
Re:Ask HN: Is it acceptable to use a date as a primary key f... by LorenzoGood on Thursday December 28, 2023 @07:03PM (#38800274)
The current schema is for a newsletter, where data needs to be stored for each individual day, but only one record needs to be created. I just realized that I can have a year, week, and day of week integer instead.
Re:Ask HN: Is it acceptable to use a date as a primary key f... by chanks on Thursday December 28, 2023 @08:53PM (#38800983)
You can, but that won't protect you against invalid dates like an actual date type will.
Re:Ask HN: Is it acceptable to use a date as a primary key f... by jmye on Thursday December 28, 2023 @10:17PM (#38801438)
What if you had to send a second version on a given day? Let’s say 90% of your content didn’t populate. You might want to send a 12/28/2023b version - would you want to capture both?

Feels like there are better options for this use case, with little effort.

I guess, is there a reason not use an auto-incrementing int? Serious question, maybe there’s some reason that’s a bad practice that I’m not aware of.