Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Normalize an Address

I am trying to normalize an address.

The diagram below shows the relevant tables for this question I believe. I want to know how ZipCodes should be integrated into the model. This would be for international addresses so I know that a Zip/PostalCode is not used everywhere. I think City::ZipCode is 1::0-n (I have read others saying this is not always the case but they never provided evidence). If they are correct then I guess this would be a many-to-many relationship. Since each Address can only have at most one ZipCode while a ZipCode can contain many addresses I am lost at how to normalize this model.

Since the Address may or may not contain a contain a ZipCode I need to refrain from having that as a nullable FK in the Address table.

EDIT: Just want to emphasize that the entities and attributes provided are drastically scaled back from the actual DB. It is only used as a reference and to address my concern of where to include zipcodes into the model.

enter image description here

like image 738
swisscheese Avatar asked Apr 03 '11 15:04

swisscheese


People also ask

How should an address be normalized?

Address standardization (or address normalization) is the process of checking and correcting address records to a standard format, according to an authoritative database (USPS in the United States). It involves checking for spelling, formatting, and abbreviation errors, and corrects addresses to a normalized format.

What does it mean to standardize an address?

When an “address is standardized,” it means that the relevant details (i.e. street number, apartment number, street name, city, state, and postal code) are in the correct formats.

What is USPS address standardization?

Address Standardization: The process of converting addresses to conform to USPS conventions by changing “Avenue” to “Ave”, replacing “#” with “STE” and other uniformity standards. The data first needs to be matched against the USPS database for it to be considered standardized.

How do I validate my address with USPS?

Use www.usps.com to check the ZIP Codes in your list. Process your address list through CASS-certified software. Address List Correction Service. You can submit a printout of your list to the Postal Service and we will mark any changes.


1 Answers

To normalise the schema you have; add a table Address-ZipCode table, with foreign keys Address ID and Zip Code; and primary key Address Id - identical to that in the Address table. Then include the Zip codes by using a Left Join between address and the new table. The new table will only be populated when an address has a zipcode.

However, I would suggest that if you are trying to accommodate international addresses, the schema you have is likely to be inadequate - you will need multiple address lines and more levels of category than shown in your diagram. Categories missed include country, sub-region, town, and possibly others.

My answer here (which is extremely long) shows what is needed to deal with international addresses (and other things) comprehensively. This is massive overkill unless you are dealing with millions of addresses in each of multiple countries.

like image 155
Chris Walton Avatar answered Oct 06 '22 06:10

Chris Walton