views:

22

answers:

1

Hi, One of my php application can have ability to create a collection with different pages(page id keep as primary key and collectionid as foreign key).After creating the collection we can edit it or delete it.Now when we are edit the collection I am deleting all the entries which matches collection id and reinsert pages with new page id and same collection id.Please suggest me some more idea to do the same without changing the pageid. Thanks

A: 

Option 1 - Create look-up table that will store (hash_value, page_id). Every time you generate a page and insert it, create hash (md5, sha1, etc..) and store it in lookup table with page id. After you delete all the records, and before you re-insert new pages into the collection get the page hash and get the id from look-up table by the the hash.

Option 2- instead of deleting the record, mark as inactive. When reinserting if record is marked as inactive, simply activate it.

Alex