0

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.

kishh143
  • 3
  • 1

1 Answers1

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
  • Is there any limitations using this zeroth row? – kishh143 Jun 18 '15 at 09:35
  • 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
  • Thanks @AHiggins ! I appreciate your response :) – Anuj Tripathi Jun 18 '15 at 12:23