title: Hash Function For Sequence of Unique Ids (UUID)
body: <p>I am storing message sequences in the database each sequence can have up to <code>N</code> number of messages. I want to create a hash function which will represent the message sequence and enable to check faster if message sequence exists.</p>
  
  <p>Each message has a case-sensitive alphanumeric universal unique id (UUID).
  Consider following messages <code>(M1, M2, M3)</code> with ids-</p>
  
  <p><code>M1 - a3RA0000000e0taBB
  M2 - a3RA00033000e0taC
  M3 - a3RA0787600e0taBB
  </code></p>
  
  <p>Message sequences can be</p>
  
  <p><code>Sequence-1 : (M1,M2,M3)
  Sequence-2 : (M1,M3,M2)
  Sequence-3 : (M2,M1,M3)
  Sequence-4 : (M1,M2)
  Sequence-5 : (M2,M3)
  </code>
  ...etc...</p>
  
  <p>Following is the database structure example for storing message sequence </p>
  
  <p><a href="https://i.stack.imgur.com/v2b02.png" rel="noreferrer"><img src="https://i.stack.imgur.com/v2b02.png" alt="enter image description here"></a></p>
  
  <p>Given the message sequence, we need to check whether that message sequence exists in the database. For example, check if message sequence <code>M1 -&gt; M2 -&gt; M3</code> i.e. with UIDs <code>(a3RA0000000e0taBB -&gt; a3RA00033000e0taC -&gt; a3RA0787600e0taBB)</code> exists in the database. </p>
  
  <p>Instead of scanning the rows in the table, I want to create a hash function which represents the message sequence with a hash value. Using the hash value lookup in the table supposedly faster.</p>
  
  <p>My simple hash function is-
  <a href="https://i.stack.imgur.com/eqa8J.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eqa8J.png" alt="enter image description here"></a></p>
  
  <p>I am wondering what would be an optimal hash function for storing the message sequence hash for faster is exists check.</p>