Jump to content
Panta

How to rename new values to avoid duplication

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

But if you make the timestamp part of title, you would not have duplicates, the user enter title for image, on saving to database you would concatenate the timestamp to title, in a format of your liking.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...