sw45acp Posted February 10, 2010 Share Posted February 10, 2010 I'm interested in knowing which is a better alternative when working with mysql. If a record needs to be deleted using a php script, is it better to actually delete the record itself or instead mark it as deleted, such as having an extra column where deleted = 1 and active = 0. Advantages of not actually deleting the record means that if the deletion was accidental, its still there. However, a disadvantage is that more space is taken up. Fully deleting a record leaves overhead in the table, and if the records have an index that is auto incremented, a number is wasted, not that it means very much. But if records will be deleted frequently the overhead will get quite large, and can be annoying to have to optimize the table. What do you guys think is the better alternative? Quote Link to comment https://forums.phpfreaks.com/topic/191698-mysql-deleting-records-or-marking-them-as-deleted/ Share on other sites More sharing options...
Philip Posted February 10, 2010 Share Posted February 10, 2010 Depends on what it is going to be used for. Quote Link to comment https://forums.phpfreaks.com/topic/191698-mysql-deleting-records-or-marking-them-as-deleted/#findComment-1010423 Share on other sites More sharing options...
sw45acp Posted February 10, 2010 Author Share Posted February 10, 2010 True, I think I will just use the php optimize table syntax after any deletion is made. Quote Link to comment https://forums.phpfreaks.com/topic/191698-mysql-deleting-records-or-marking-them-as-deleted/#findComment-1010441 Share on other sites More sharing options...
waynew Posted February 14, 2010 Share Posted February 14, 2010 If that "deleted" data (i.e active=0) could be useful later on, just mark it as inactive. If it's data that won't be useful later on, just delete it. Quote Link to comment https://forums.phpfreaks.com/topic/191698-mysql-deleting-records-or-marking-them-as-deleted/#findComment-1012174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.