Friends, we knew that primary key is to identify a row in a table and surrogate key is also for same purpose like primary key. But why we need surrogate key and primary key in a table?
Let’s discuss it here.
Suppose I have two different sources and needs to be loaded only one target from these two sources.
Assume, Source1 is Oracle table and Source2 is Flatfile.
Field1 is a primary key in both the sources. Suppose you are getting values 1,2 for field1 from source1 and values 1,3 for field1 from source2. When you try to load target from both the sources, it will create duplication of primary and it will throw “primary key constraint violation” error. So we will go for surrogate key concept.
I think, this is very useful information because many people face this question in interviews.
If you have any questions, please feel free to write to kkrishnareddychp@gmail.com
Comments
Post a Comment