We have a set of template files which can be copied by users and modified later. We have a unique constraint on the "name" field, so when some user copies a template file say "File 1" we add it as "Copy of File 1" and if he copies a template fi开发者_运维技巧le say "File 2" we add it as "Copy of File 2" (i.e. we add an appropriate prefix, when we copy these files) so we don't violate the unique constraint.
But if he adds the same file "File 1" again we run into a unique constraint violation error, what kind of naming convention should I follow, so that I can make it intuitive enough for the end user.
You could add the date of when the copy was made to the filename. Adjust the precision to the time frame least likely to cause a problem.
e.g. File1 -> File 1 - Copy 2010-12-29 0017
Also, I prefer suffixes to prefixes for copies so that the copy is stored next to the original.
Do the something similar what the explorer of win7 does when you drag-and-drop-copy a file within the same folder:
index.html
index - Copy.html
index - Copy (2).html
index - Copy (3).html
精彩评论