May 12, 2009 at 9:03 am
So I'm speaking with a developer about a change he wants to do to a table in our production system.
Here's the gist of the discussion.
The developer doesn't want NULLs in the database. yet he's asking me to declare foreign keys for columns that may not have a match in their primary table. His way of working around that is to put a row with a PK of -1 in the table and put -1 values into the foreign key field when the information he wants isnt there.
I know that this is the result of two things.
1. fear of NULLs and the special handling that this may require.
2. bad practices that were exercied in the past.
I'd like to correct this developer and point him to reference material that explains why using -1 (or any other number) for all the foreign key values that he doesn't know the matching key to is bad practice and that he should use NULL instead. My gut tells me its bad, and I Know I've read in various articles that its bad practice, but I'd like something I can refer him to to explain it.
So far my google fu keeps turning up how to declare a foreign key, not DB theory on proper practices with it, so any web references to articles on the subject would be appreciated.
Thanks!
May 12, 2009 at 9:17 am
I'm not sure I have an article specifically addressing this, but moving all data to a specific key can be an issue later with untangling them. NULL is there for an "unknown" or "I don't know" situation.
that doesnt' work with FKs, so you need to set FKs for places where that's a real realationship. If you don't have that for all children, is it a real relationship? It could be, and having a placeholder might make sense, but I think I would be tempted to have multiple parent placeholders that map them.
It would be good to better understand what the entities actually mean here.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply