SQL Server Nullable Foreign Key Normalization Question

Hello all,

I have an application that has a table currently Customer that has a non nullable field LocationId.  It is a 1 to 1 relationship currently.   We have determined that we have to decouple the LocationId as the Customer may not have a location.   Right now the LocationId is a FK in the Customer table to a PK table called Location.

The question is this should we just make the LocationId a nullable field in the Customer table.   This causes least impact on changes we need to make as we use Entity Framework in our app and it's everywhere.    The other option is making a table called CustomerLocation that has the two PK fields CustomerId and LocationId and deleting it from the Customer table.   This really looks to be a many to many although I can put a constraint on it.   This though we have to in our app go after the FirstOrDefault record everywhere.  If it is best to do it this way then we will just have to bite the bullet.

Any suggestions what is the best practice here?   Having a nullable FK not sure is best but impact is higher on the app code.

Thanks all
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
There is nothing wrong with having a nullable foreign key field and that is the route I would suggest.
Scott PletcherSenior DBACommented:
If it is (still) a 1-1, and you expect that it will remain a 1-1 even though you've decoupled them, then I would use a nullable foreign key.  There's absolutely no design issue with that, if the data is truly a zero or one occurrence, never more than one.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony PerkinsCommented:
If on the other hand two or more customers can have the same location then your second option would make more sense.
sbornstein2Author Commented:
awesome thanks all.   Appreciate the feedback its going to be a 0 to 1 or 1 to 1.
sbornstein2Author Commented:
thanks all.  giving the top points to Scott good explanation I can use to back myself up as well 0 to 1 or 1 to 1.  Thanks all for the feedback.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.