I have come across a OLTP Database where all the tables has a default row,value 0 for a primary key and other columns with its default value or a null value.I am not sure why is this row required in first place? can anyone explain what are the advantages and disadvantages of having zeroth row.
Asked
Active
Viewed 70 times
0
-
2Default value for Foreign Keys to represent "Unknown", is one possibility. – mxix Jun 18 '15 at 08:32
-
Thanks, that would be the main reason behind using a zeroth row. is there any other advantages using this. – kishh143 Jun 18 '15 at 08:45
-
Some extra reading on the same topic: http://stackoverflow.com/a/983431/1225845 – AHiggins Jun 18 '15 at 14:26
1 Answers
2
Having zeroth row is related to business rule or specifications. For example, you have a data warehouse where you are loading data for customer and by mistake your customer haven't provided any country name then you might need to provide him a default value (which could be anything, in your case it is zero). Consider below example
CREATE TABLE #TestTable (
PrimaryKeyColumn INT NOT NULL ,
CONSTRAINT PK_PKC PRIMARY KEY CLUSTERED (PrimaryKeyColumn),
CountryName varchar(100))
INSERT INTO #TestTable VALUES (0,'No Country Found'),(1,'USA'),(2,'Canada')
SELECT * FROM #TestTable
DROP TABLE #TestTable
I have designed a data warehouse where I have reserved value 1,2,3,4,5 for different default scenarios. The reason we do it because no matter data is correct or not but still it is important. Just like customer case, where we don't know his country but we are concerned about the order he deals with.
Though, I should have post this in comment but due to < 50 reputation I have posted it as an answer.

Anuj Tripathi
- 2,251
- 14
- 18
-
-
No limitation related to it. but removing that row from you existing system may cause error as it may be used as a default value for application. – Anuj Tripathi Jun 18 '15 at 09:38
-
2@anujtripathi, by including details and an example in your answer, you made it much better than a simple comment and were able to provide the OP with what they needed ... this is a good answer in my book. Enjoy your > 50! – AHiggins Jun 18 '15 at 12:21
-