Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:46:29+00:00 2026-06-14T12:46:29+00:00

I’m attempting to build a database table that holds zip code data (that is

  • 0

I’m attempting to build a database table that holds zip code data (that is then later referenced in my application).

I am grabbing the .csv file from http://www.populardata.com/zipcode_database.html which has the following data:

  • zip
  • latitude
  • longitude
  • city
  • state
  • county
  • zip_class

What I’ve attempted so far is:

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

But since I’m newer to MySQL, best-practices, etc. have snuck up on me. For example, the zip table seems to strip the beginning of the zip codes. I looked into ZEROFILL but I don’t think that’ what I want here, I basically want to use zip as an int field, but have it not auto-correct the data inside of it (or truncate it).

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:46:30+00:00Added an answer on June 14, 2026 at 12:46 pm

    You probably don’t want to store a ZIP code as an integer field, because it’s not really an integer. It looks like one, but it wouldn’t make sense to perform integer operations on it (e.g. You would never do 12034 + 32523 – it would be nonsensical).

    It would be better to store this as a char(5) field, because really that’s what it is – a 5 character string, that happens to be constrained to only contain digits.

    EDIT

    Latitude and Longitude can be stored as a numeric datatype (probably a decimal or double) as they actually are numbers 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.