I need to have three columns in all my tables to reflect these as per requirements:
- Create date/time -> Date and time the row was created. This value should never change forever.
- Modified date/time -> Date and time only portions of the row was last modified. This value will always change if any detail in the row is changed.
- Updated date/time -> Date and time the entire row was last updated. This value will always change if all details in the row is changed.
In addition I need to maintain same details but at table level->
- date/time table was created
- date/time the last row was inserted
- date/time last edit took place.
So two questions:
1) For the 3 row cases of date/times: Which one needs to be datetime and which one timestamp?
2) For the 3 table level date/times: Can I store this in the same table somehow or do i need a separate table to store this info, and what functions can i use for this?
End goal is to automate these date/times, because lot of data like for lookup tables will be entered/edited by end users from the front end so I need the DB to do all date/times on its own in the back without any manual insertions for these colunms.
Also, I need to perform reporting on these date/times, hence need to ensure they can be manipulated at the code level for breaking down the date/times into days, weeks, months, years, hours & minutes.