title: SHA1 sum as a primary key?
body: <p>I am going to store filenames and other details in a table where, I am planning to use sha1 hash of the filename as PK.</p>
  
  <ul>
  <li><p>Q1. SHA1 PK will not be a sequentially increasing/decreasing number.
  so, will it be more resource consuming for the database to
  maintain/search_into and index on that key? If i decide to keep it in database as 40 char value.</p></li>
  <li><p>Q2. I read here:
  <a href="https://stackoverflow.com/a/614483/986818">https://stackoverflow.com/a/614483/986818</a> storing the data as
  binary(20) field. can someone advice me in this regard:</p></li>
  <li>a) do i have to create this column as:  TYPE=integer, LENGTH=20,<br>
  COLLATION=binary, ATTRIBUTES=binary?</li>
  <li>b) how to convert the sha1 value in MySQL or Perl to store into the
  table?</li>
  <li>c) is there a danger of duplicacy for this 20 char value?</li>
  </ul>
  
  <p>**</p>
  
  <blockquote>
    <p>---------UPDATE-------------</p>
  </blockquote>
  
  <p>**</p>
  
  <p>The requirement is to search the table on filename. user supplies filename, i go search the table and if filename is not there adds it. So either i index on varchar(100) filename field or generate a column with sha1 of the filename - hoping it would be easy for indexing for MySql compared to indexing a varchar field. Also i can search using the sha1 value from my program against the sha1 column. what say? primary key or just indexd key: i choose PK coz DBIx likes using PK. and PK or INDEX+UNIQ would be same amount of overhead for the system(so i thought)</p>