title: Building Database Table for Zip Codes
body: <p>I'm attempting to build a database table that holds zip code data (that is then later referenced in my application).</p>
  
  <p>I am grabbing the <code>.csv</code> file from <a href="http://www.populardata.com/zipcode_database.html" rel="nofollow">http://www.populardata.com/zipcode_database.html</a> which has the following data:</p>
  
  <ul>
  <li>zip</li>
  <li>latitude</li>
  <li>longitude</li>
  <li>city</li>
  <li>state</li>
  <li>county</li>
  <li>zip_class</li>
  </ul>
  
  <p>What I've attempted so far is:</p>
  
  <pre><code>CREATE TABLE `finder_zip_codes` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `zip` mediumint(128) DEFAULT '0',
    `latitude` varchar(128) DEFAULT NULL,
    `longitude` varchar(128) DEFAULT NULL,
    `city` varchar(128) DEFAULT NULL,
    `state` varchar(128) DEFAULT NULL,
    `county` varchar(128) DEFAULT NULL,
    `zip_class` varchar(128) DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>But since I'm newer to MySQL, best-practices, etc. have snuck up on me. For example, the <code>zip</code> table seems to strip the beginning of the zip codes. I looked into <code>ZEROFILL</code> but I don't think that' what I want here, I basically want to use <code>zip</code> as an int field, but have it not auto-correct the data inside of it (or truncate it).</p>
  
  <p>Any help would be greatly appreciated - I've been trying a few doc sites and this is what I've come up with so far - so any additional tips would be awesome. Thanks!</p>