Hi folks,
Overview
I'm working on some Emergency Services reporting and mapping application for California (kind of weird, considering the fires there, right now...). We need to map demographic and emergency data for an internal govt unit.
What we have are all the streets, cities and neighborhoods in California. Each neighborhood also has it's relevant shapefile (lat long that defines it's boundaries). This was given to us by the US Census board (all public domain stuff) website.
Problem
I'm not sure how to best design the DB tables. We haven't been told what type of DB we need to use .. so we're open to suggestions if that helps. We have experience with MS SQL 2005 and 2008 (and the spatial stuff in '08).
We can have the following legit data.
- Street, City, State
- City, State
- Neighborhood, State
- State
The reason why State is a legit location is because we're told this might be sold to other states, so we need to plan for that now.
So, originally, i thought of this...
- LocationId INTEGER PK Identity
- Street NVARCHAR(100)
- Neighbourhood NVARCHAR(100)
- City NVARCHAR(100)
- State NVARCHAR(100)
- Latitude VARCHAR(15)
- Longitude VARCHAR(15)
- Shapefile
None of those are nullable, btw. But after a short while, i thought that it was a waste to have so many 'California' text or 'San Diego' text in the fields. So i changed the table to be more normalised by making the Neighborhood, City and State fields a foreign key to their own new table (eg. lookups) .. and those two fields are now NULLABLE.
So .. that all works fine. except when i try and do some Sql statements on them. Because of the NULLABLE FK's, it's a nightmare to make all these outer join queries :(
What about having the main table, the sub-lookup tables (eg. Neighbourhoods, Cities and States) linked via ID's and then place all this in a view? Remember, NeighborhoodID and CitiyID would be NULLABLE.. ???
I just want to see people's thoughts on this and the reasons they made their suggestions, please. I'm really worried and confused but are eager to learn.
Please help!
edit 1: I need to stick to an RDBMS Database.
edit 2: I'm thinking about going a single table (de-normalized) with constraints to keep the sum of the fields unqiue OR multi-tables with nullable FK's on the main table (eg. Locations (main table), Neighborhoods, Cities, States ... normalized db schema).
edit 3: Added City to the sample, second list.
edit 4: Added view question.