0

I was looking for a solution of generating readable, short, unique strings in order to store files in database. (file's ID = generated string). I have found this answer Generating human-readable/usable, short but unique IDs. According to the answer: you will have to store the created IDs and check for duplicates on creation to ensure uniqueness. The question is: is it efficient to compare such strings each time the ID creation is done? Does it mean we have to compare every single row to check whether a duplicate exists?

DominikS
  • 361
  • 3
  • 13
  • 1
    This is what unique indexes are good at; the data's already sorted so checking for duplicates can be an efficient operation. – Joe Feb 21 '18 at 22:36
  • Okay, so let's say it's efficient when it comes to database storage, but I want to include Entity Framework here also. Does following query in EF: "from c in context.Files where c.FileId == id select c;" will fetch and map to object only these rows with given id or all rows? – DominikS Feb 22 '18 at 10:01

0 Answers0