j.silver Posted November 29, 2016 Share Posted November 29, 2016 Dear all, For an e.commerce project, I have the following for a carts table, which seem to be the practice in assigning date/time to such table: `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `date_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', What are the merits in assigning default values as such for each date? Link to comment Share on other sites More sharing options...
Ingolme Posted November 29, 2016 Share Posted November 29, 2016 Starting date_modified at zero can indicate that the item has never been modified before. date_created has to be set as soon as the row is created. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 29, 2016 Share Posted November 29, 2016 You have to use a default value if you define the column as not null, but don't include those columns in the insert statement. You can allow null values in a column and then if you don't include them in the insert they will default to null. date_modified would make more sense to default to a null value instead of a point 2016 years ago. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now