Skip to main content
11 votes

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

it's a great practice Marking and unmarking a record as most recent is trivial. Having a simple bit field to point you to the rows you care about is far easier than going out to find the most recent ...
Erik Darling's user avatar
  • 40.8k
9 votes

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

Another common pattern for SCD is to have a pair of datetime columns effective_date and end_effective_date. This allows both identification of the current version (using null or some fixed future ...
David Browne - Microsoft's user avatar
5 votes

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

It seems simpler in the long run to add the extra 'current' field, and like it would be more performant, but is it also bad practice? If your table absolutely has to be SCD, it's a good idea. For 99%...
Quassnoi's user avatar
  • 641
4 votes

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

I'd discourage anything that requires extra bookkeeping or potentially leads to confused data. 3NF says that adding the flag is wrong since it is dependent on the create date—what row should you look ...
Michael's user avatar
  • 41
3 votes

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

Modifying existing data when you create a new record is not good practice (depending on how secure your data is). If you need to keep old data around for security/audit reasons, you should treat it ...
Neil's user avatar
  • 181
2 votes
Accepted

How to let you change the order of products?

But now they want that the administrator can change the order, so he can set a custom order. Which is the best way to implement this? You would want to add another column to your products table ...
J.D.'s user avatar
  • 37.5k
1 vote

MySQL design and best design practices

My advice is to not do it at all but buy a 3rd party SaaS option such as Auth0 (no affiliation). You get the benefit of being able to federate with corporate identity providers (if that's your market) ...
LoztInSpace's user avatar
1 vote

Is it bad practice to have a "most_recent" boolean column in addition to a "create_at" timestamp column to track the latest version of a record?

If a new boolean most_recent column adds value or is more of a burden depends on the situation. Compare this to adding an index to a table for faster lookups. Adding a new row will be slower because ...
Roland's user avatar
  • 111
1 vote

How to let you change the order of products?

As you can see it's a custom order, it doesn't sort by id but it is decided by the administrator, and I want that this order remains for every user, so it shouldn't be lost when page is refreshed. ...
Ergest Basha's user avatar
  • 3,935
1 vote
Accepted

Best design pattern for Posts and Comments, whereas Comments are also Posts

Your proposed approach resembles the standard employee table with a managerid, so this is not an obviously stupid one. You will be able to query this with standard queries used on such an example ...
Cong Chen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible