Downloaded pdf for searching and code copying ($10).
Excellent. Paper book had said offer expired 2007 but it didn't :up:
Favorite quote so far ('yeah, cos I've always preached it myself of course…):
To track record additions and updates, tables should have fields called created_on or created_at and updated_on or updated_at. If these fields exist within your table, Active Record will automatically populate them with the timestamp when records are created for the created_on or created_at field or when records are updated for the updated_on or updated_at field. If you prefer to use another field name for either of these, you can just use callbacks to keep these fields properly updated.
Also nb (I didn't know this)… Active Record assigns values to all fields within a table. When you save a new Active Record object or do an update on an Active Record object, Active Record actually assigns a value to every field within the table in the database. If you haven’t set a value for a given field, the field will be set to nil. This is important to remember, because it means default values set up within your database (like a timestamp) will most likely not be triggered since a specific value is provided (nil) for the field.
I'd add that if you put them (and userID stamps) in all tables, even many-to-many links, then you can have global methods for them. The fields are always very useful for debugging / testing / researching issues even if not needed for front-end (so actual usage will depend on volume of site, etc.).
2nd Add – make fields not null when possible and for look-up tables, when possible, make the main field, e.g. album_name or organization or paper_style or whatever have UNIQUE constraint. Helps a lot in preventing errors. Constraint (not field) can always be dropped!