View Single Post
  #1 (permalink)  
Old 02-14-09, 12:49
nineinchnailgun nineinchnailgun is offline
Registered User
 
Join Date: Mar 2008
Posts: 11
Never modifying data: Are pointers a good solution?

I run a website that stores a lot of user-generated data. Currently, I allow them to modify records. Say someone rates a product as 3 out of 5 stars today. Tomorrow, they can change that to 5/5. When they do so, the record is simply updated.

I'm thinking that I'd rather have all of the data - to know the data's history - and I'm considering different ways of doing this. One way that I'm considering is to use a "pointer" (for lack of a better word). I'd insert the new rating into the table, snag its ID, and then update its parent to add the child's ID into its previously null "pointer" field. An example of one item that has had its rating modified is below:

Code:
ID | Product | Rating | childID
1  |  Flowers  |  3  |  2
2  |  Flowers  |  5  |  NULL
The reason I like this approach is that the freshest data can be isolated by searching for all records where childID is null. However, are there other general approaches to data persistence that might be more efficient? Any feedback would be greatly appreciated.
Reply With Quote