I am designing a database for a site which will be heavily datadriven with forums and chat and other community features.
My question is this: I have identified certain information I would like to store for at least most of the tables. Creation date, last update, creator and others.
Which is the best way to store these, in a dedicated table or as fields in each respective table?
Why is the better solution better?
Can the opinion of best solution change if I have 50 tables or 100 tables?
100 000 records vs 4 million?
Are there other aspects?
Creation date and last update date are best stored as columns in the same table with their respective data. By doing that, you can use the
TIMESTAMPdata type so they are updated automatically when their respective rows change.The
NULLtimestamp on therow_createdcolumn will default to the timestamp when the row is created. Inrow_updated, the timestamp will be updated automatically every time the row is modified in any way. You do not need to modify them in application code.The creator user isn’t as critical to store in the same table, but it doesn’t really hurt to do it in the same table or another. For simplicity I would keep it in the same table.