Are two fields created and modified that each database table should have?

I recently realized that I’m adding some form of timestamp to create a row and maybe the field is β€œupdated” for most of my tables. Suddenly, I began to think that perhaps every table in the database should have a created and modified field that are installed in the model behind the scenes.

Does this sound right? Are there types of high-load tables (like sessions) or massive tables for which this would not be a good idea?

+4
source share
2 answers

I would not put these fields (which I usually call audit fields) in each database table. If it is a table with low traffic and high cost (for example, Users , for example), this continues, not a question. I would also add creator and modifier . If this is a table that falls into the lot (say, a history table of operations), then perhaps the advantage is not worth the cost of increased insertion time and storage space.

This is a challenge that you will need to make separately for each table.

+5
source

Obviously, there are no rules.

Most of my tables have date-related things, DateCreated, DateModified, and sometimes Revision for tracking changes, etc. Do whatever makes sense. It is clear that you can come up with cases where this is appropriate and cases where it is not. If you ask whether to add them by default to most tables, I would say "maybe."

+1
source

All Articles