title: Saving combinations of ids with volume
body: <p>I am trying to create a system where users can create grocery lists containing products with thier volumes.</p>
  
  <p><strong>Background.</strong></p>
  
  <hr>
  
  <p>The application I am designing takes in a grocery list containing the ids of products with thier amount that are being ordered. The grocery list that has been ordered by user A should be available to user B and all other users. Users also get to see the grocery list that has been ordered the most and each grocery list must also contain the amount of each product in this list.</p>
  
  <p><strong>(possible) Solution.</strong></p>
  
  <hr>
  
  <p>One solution I could come up with is to generate a unique hash from these lists. Take the id of the product and multiply that with the volume and add each of these values to come up with the hash value for this particular list. Create two tables.</p>
  
  <ol>
  <li>Containing the hash value with the amount of times poeple ordered this list.</li>
  <li>A lookup table using the hash as unique id and containing the actual products with the amount.</li>
  </ol>
  
  <p>This way you can immediatly see the lists that has been ordered the most and you can get the content of this list.</p>
  
  <p><strong>Problem.</strong> </p>
  
  <hr>
  
  <p>One really big problem is that I am afraid of hash collisions when calculating the hash value of the lists.</p>
  
  <p>Is there any other 'easier' or 'better' way to solve this problem and/or what hashing algorithm should I be using when sticking to my own solution. </p>
  
  <p><strong>Edit 1.</strong></p>
  
  <hr>
  
  <p>The suggestions made in the comments could indeed make a viable solution. However there is still something that is bugging me. Say for instance a list exists with two items: item A with volume 2 and item B with volume 3. Some people use this list to order immediatly while others prefer making their own lists. With this solutiuon there is no easy and fast way to discover if a new list has already been submitted by someone else before. Before saving the list I'd have to check with every existing list if the volume and items match before either updating the existing list or adding a new one. </p>
  
  <p>Would this matter query-wise for a database that contains about 50.000 to 100.000 lists or am I creating problems that don't exists for this scenario?</p>