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

  • SEARCH
  • Home
  • 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 7037431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:32:39+00:00 2026-05-28T01:32:39+00:00

I’m working on an application that is location specific — think of it as

  • 0

I’m working on an application that is location specific — think of it as a store locator where store owners enter their address information and other users can only see nearby stores within a certain range. However, it’s a little different in the sense that an exact location is not required, only the city/state is required (weird, I know). I have thought about the schema for storing locations, and have decided on this one.

Locations

id                      -- int
formatted_address       -- varchar(200)
is_point_of_interest    -- bool
name                    -- varchar(100) -- NULL
street_number           -- varchar(10)  -- NULL
street                  -- varchar(40)  -- NULL
city                    -- varchar(40)
state                   -- varchar(40)
state_code              -- varchar(3)
postal_code             -- varchar(10)
country                 -- varchar(40)
country_code            -- varchar(3)
latitude                -- float(10,6)
longitude               -- float(10,6)
last_updated_at         -- timestamp

Here are some notes about the application:

  • I want to keep the door open for international locations
  • I plan to use a geocoding service to search for and validate the locations specified by the store owner
  • I truly only need the lat/lon, but the other data is necessary for displaying store information
  • The formatted_address field will contain the fully formatted address — e.g., Giants Stadium, 50 NJ-120, East Rutherford, NJ 07073, USA — to allow for easier searching of stored locations
  • There will possibly be a lot of duplicate fields, because each row may have a different level of granularity — for instance, 123 Main Street, City, State 12345 is different from Main Street, City, State 12345 because one has a specified street number and the other doesn’t

I understand that the schema is not very normalized, but I also do not see the need to normalize it any more because locations are very complex, which is why I’m relying on a stable geocode service (google). Also, I plan to allow freeform text input/search, so theres no need for any dropdown lists.

Does anybody see anything wrong or have any improvements, taking into consideration what I’ve mentioned? I can see this table growing rather large.

  • 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-05-28T01:32:40+00:00Added an answer on May 28, 2026 at 1:32 am

    I do not think so. Here is my two-minute synopsis:

    This very badly normalized. At least city->country should be moved out to a different table (and normalized from there). I believe postal codes can cross city boundaries though (or I am very badly misremembering); I am not aware of such a city that crosses a state boundary.

    formatted_address is an “optimization” and should likely be a computed field: that is, all the data to re-create it should exist elsewhere. (This means that it doesn’t need to worried about now.)

    Happy designing.


    The simple “more-normalized” form just doing the above proposed:

    LOCATIONS
    location_id             -- int
    is_point_of_interest    -- bool
    name                    -- varchar(100) -- NULL
    street_number           -- varchar(10)  -- NULL
    street                  -- varchar(40)  -- NULL
    city_id                 -- int
    postal_code             -- varchar(10)
    latitude                -- float(10,6)
    longitude               -- float(10,6)
    last_updated_at         -- timestamp
    
    CITIES
    city_id                 
    name                    -- varchar
    -- similarly, the following should be normalized to STATES and COUNTRIES
    state                   -- varchar(40)
    state_code              -- varchar(3)
    country                 -- varchar(40)
    country_code            -- varchar(3)
    

    Of course, CITIES can be further normalized, and so could a POSTALS table: I don’t know enough about postal codes, or the application domain though. postal_code acts as part of an implicit compound-surrogate-FK so it’s not super terrible as it is there. However, moving it into a separate table could easily allow verification and integrity constraints.

    Edit: Normalizing a POSTALs table would be best, as only a very samll number of postal codes are valid for a given city: I am not sure the relation between a postal code and a city, though, so I can’t recommend how to do this. Perhaps look at existing schemas used?

    • 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
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
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 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
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT

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.