Jump to content

How to rename new values to avoid duplication


Panta

Recommended Posts

Good day, please am having a problem,

I have a site that i want people to upload a picture and also fill the tittle, now the tittle value will be returned to a DB , but i want to avoid duplication of values in same row because some will use the same tittle for most of the pictures they want to upload. please how do i assign a new value to the tittle if my query founds out that value already exists. Thanks

Link to comment
Share on other sites

This could introduce various complications that could cause you trouble if you don't handle them correctly. I doubt it is worth the bother. Let's say that when an image is uploaded you search the database for the given title to see if it already exists. You find it and assign that title id to the new image. Later the user edits some of the image titles. After each edit you would have to again search the database to see if the new title already exists and create a new entry if the title is now unique. You would need a separate table for these titles. Also you would need to occasionally search the table for orphaned titles.

Link to comment
Share on other sites

Maybe use/add a timestamp for title OR image 'My Images - date: 2015-02-22-22-00-00', 'myimage-2015-02-22-22-00-00.jpg', so you can compare 'myimage.jpg' to date/time it was saved, if user saves updated image of 'myimage.jpg' the image stored in database would be updated to timestamp stored, and the image should be saved to reflect that it was a new edited version of same image 'myimage-2015-02-22-22-30-00.jpg.

Link to comment
Share on other sites

Maybe use/add a timestamp for title OR image 'My Images - date: 2015-02-22-22-00-00', 'myimage-2015-02-22-22-00-00.jpg', so you can compare 'myimage.jpg' to date/time it was saved, if user saves updated image of 'myimage.jpg' the image stored in database would be updated to timestamp stored, and the image should be saved to reflect that it was a new edited version of same image 'myimage-2015-02-22-22-30-00.jpg.

i guess davej understood my problem, what i wanted is to have a tittle,text box beside the picture upload for each picture, am not editting the picture name, am allowing the user to input the picture tittle,whilr the file retains its orginal name.

@davej what do you suggest on how i can handle this kind of thing, is there a way out. thanks dsonesuk @davej for your contributions

Link to comment
Share on other sites

I would suspect that most images would be left without a title unless you auto-generate one (as Dsonesuk suggests) or allow the user to easily set one for multiple images. Are you concerned about the website appearance or the duplication of the data? A text string is very small and should not be a significant problem for the database to manage.

Link to comment
Share on other sites

Oh thanks to you all for your contributions , i think i will go with the timestamp, it solves the problem......once more i appreciate

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...