Sql-server – SQL table for Address and Localization

database-designsql server

I need to save a list of Places and Persons in a Database including their Addresses and Latitude / Longitude. Sometimes I have an address other times only Latitude / Longitude other times none. So I have:

create table dbo.Persons (
  Id int identity not null primary key clustered (Id),      
  AddressId int not null,   
  Name nvarchar (100) null,
  Localization geography null
)

create table dbo.Places (
  Id int identity not null primary key clustered (Id),      
  AddressId int not null,   
  Name nvarchar (100) null,
  Localization geography null
)

create table dbo.Addresses (
  Id int identity not null primary key clustered (Id),      
  CityId int not null,
  Street nvarchar (100) null,
  PostalCode nvarchar (100) null,
)

create table dbo.Cities (
  Id int identity not null primary key clustered (Id),      
  Name nvarchar (100) null
)

I have two questions:

  1. Should I move the Localization from Places and Persons to Address?
    I am doing this way because I can have an address and not a Localization or vice versa.

  2. Is there a way to improve my database scheme?

Best Answer

I'd move localization to Addresses. You'd probably like to know where an address is located anyway. Some people have many addresses (a fiscal address, shipping address, multiple houses) And some addresses belong to many people (families, companies...) Consider creating a many to many table that relates Persons and Addresses.