Updating customer details
I have a website which stores customer details, name, address, contact etc. A customer can update their own details via a form. What are the best practices for implementing this?
Do I just use an UPDATE
statement over the existing data, or do I have old and new details?
It got me thinking, say if using a webiste such as amazon when a开发者_高级运维 customer updates their details. What if the details are not correct? Do amazon have a record of the old details as a backup?
Such as a customer could live at 999 Fake Street. Also what if a problem occurs and the customer cannot be contacted because of the new updated details given? For example the customer receives a service and avoid paying.
Should I just update customers information, or should I move the old data into another table then update?
Hope I haven't asked too much of an obvious question, thanks.
Elliott, the database design you are seeking must be based on business rules. The DBA at facebook, twitter, amazon or Mom's Pizza did not dedtermine how many old addresses to keep. Ask the BA for the rule on address. If the answer is "keep only a current address" then implement the UPDATE statement you mentioned in the question. If the BA give you a blank stare then insert new rows for every update and display the latest chrono record and NEVER delete anything.
When the DB A recieves a complete set of business rules only then should the design begin.
Add a field to your customer table InfoDate
or something similar. Then you can access the data via a view that only shows you the record for each customer where the InfoDate
is the max value for that customer.
You keep all your data without a complicated process of migrating to another table for archiving, and you can access historical data easily by directly querying the table instead of the view.
精彩评论