Possible Duplicates:
Is there common street addresses database design for all addresses of the world?
What is the “best” way to store international addresses in a database?
Best practices for consistent and comprehensive address storage in a database
I currently have four tables, Customers, Contacts, Facilities and Clients.
Each of these tables has the following fields: AddressLine1, AddressLine2, City, StateOrProvince, PostalCode.
I would like to move the addresses out to a separate table and be able to also designate the type of address (billing, shipping, main, etc.).
My solution is as follows:
I am looking for guidance to determine if there is a better solution than the one I devised. Why does everyone think?
EDIT: I am not concerned with anything outside the US at this point and not concerned with how to store the street address, ie street number vs the whole street address. I am concerned from a database design and table structure stand point.
String data types are normally used to store names, addresses, descriptions or any value that contains letters and numbers including binary data, like image or audio files.
Within a database, what is an address? The street (and house or unit number), district, city, state, country, and zip code represent the address. Often, we immediately think of normalization (separate fields for the street, neighborhood, city, country, etc.).
A DBA where I used to work told me this gem, and it's worked great for us (the first two steps are the same as in your solution):
This way you've got all your addresses in one table, they can reference any record you need, your referential integrity is intact, and you don't have in intermediate table that you have to traverse.
The downside is that if you want to add addresses to a new class of object (e.g. an Employee table), you have to add a EmployeeID column to the Addresses table, but that's pretty easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With