views:

26

answers:

1

Sometime back while designing something that included user management, I was required to have created_by and last_updated_by columns in the User table. To me it seemed a good idea to have a 1:1 relationship on User itself as it would serve as an additional check.

The obvious issue is creating the first user who will have to create himself but after that it should work fine(?) I believe. But I was asked to remove the constraint stating some reasons. What would be a good design decision?

A: 

This answer won't we very tech related: We also using different CMS for our customers and they have a "created_at" and "updated_at" column in almost all of theis tables that relate to users, products, posts, ... One week ago, I was asked to get some stats from the application. I should get how many users were active and when, when did a user log-in and did he returned in period X. From users that are not older than 1 month (speaking application wise of course) how many have actively done something on the site and so on.

There are specialized tools for something like that, of course but the data was more than enough to provide pretty detailed information on various aspects that were very important from a financial point of view as well as planning and re-thinking some aspects.

As mentioned, this is not really a datebase-design answer but I'm sure everyone who does the econimical part will be interrested in some of this data at one point. So keeping it doesn't hurt anybody but can give you cheap (because it's "already there") information for a next meeting with the customers manager or whoever.

DrColossos
But do you, or do you not put the foreign key constraint?
Ashish
When your DBMS supports it, you should use them.
DrColossos