avatar
Logan R. Kearsley @gliese1337.bsky.social

Which is better done with a distinct boolean field marking a record as softly-deleted or not.

jul 5, 2025, 8:02 pm • 0 0

Replies

avatar
soundsilenttide.bsky.social @soundsilenttide.bsky.social

Sure, if your app is already designed with that feature. Many existing apps are not.

jul 5, 2025, 8:04 pm • 1 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

So what? Just add a column if you are using SQL, or a new ad-hoc property if you're using an unstructured document DB. Recruiting the sign but is a recipe for disaster. E.g., what happens the next time you need to add a boolean property, and the sign bit is already taken? What happens if you need...

jul 5, 2025, 8:22 pm • 0 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

...to add a new feature which requires a non-boolean property? You better have the ability to update your DB schema then. And what happens if the positive ID gets reassigned to another record (because hey, that value is unused!), and then you decide to undelete something?

jul 5, 2025, 8:22 pm • 0 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

IDs should never have any auxiliary meaning beyond being a unique ID, or you are on track to create more problems than you solved.

jul 5, 2025, 8:22 pm • 0 0 • view
avatar
soundsilenttide.bsky.social @soundsilenttide.bsky.social

Just add a column...and then rewrite all of your data access code to respect this new logic. This is a ton of work!

jul 5, 2025, 8:26 pm • 1 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

So is rewriting all your data access code to pay attention to the sign bit!

jul 5, 2025, 8:32 pm • 0 0 • view
avatar
soundsilenttide.bsky.social @soundsilenttide.bsky.social

All we are accomplishing with flipping the sign is unlinking an existing refence. That can be useful in a deployed app depending on the situation, like in production support scenarios. I would not design an app this way, but that does not mean it is not useful in existing apps

jul 5, 2025, 8:28 pm • 1 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

So you're not adding a feature, you're just manually screwing with the DB in a live support situation? Again, there are better ways, and the fact that this error may be useful in a particular scenario does not mean that it is necessary or a good idea.

jul 5, 2025, 8:34 pm • 0 0 • view
avatar
soundsilenttide.bsky.social @soundsilenttide.bsky.social

Yep sometimes a FK row needs to be separated from the parent row. And I don't want to hard delete it. That can be really problematic if there are enforced integrity constraints. And lots of FKs directly reference parent PKs. signed int keys really help here

jul 5, 2025, 8:37 pm • 0 0 • view
avatar
Logan R. Kearsley @gliese1337.bsky.social

Then again I submit that you are doing something dangerous and unnecessary, and it is just luck that it hasn't bitten you yet.

jul 5, 2025, 8:41 pm • 0 0 • view