In my legacy web application, here is the structure of customer table in sql server 2005:-
custId, custName,custAddress,custGUID
1 scott mark B36AF54E-F2B5-4845-9595-AC05K898AE14
My question is about the column custGUID which is declared as uniqueIdentifier()which is GUID). I am not getting whats the difference between primary key and uniqueIdentifier and whats the reason to introduce extra column as guid.As per different sites i came to know that uniqueIdentifier is uniques across the whole sqlserver 2005 but primary key is unique is unique in that particular table . But i am not able to think of any scenario of making any column as GUID/unique across the sql server. Want to understand
when and how does GUID column makes sense? As all team meamber are new, not able to figure out the mystery
This is a tough one to answer, as there are many reasons to do this, most of them not good at all.
You might be looking at a legacy application, where data was stored across multiple servers. To avoid having data overwritten when the data is was finally merged, a GUID column was introduced.
I’ve seen this in applications before where, for example, staff had a copy of the program on their laptops, and were working remotely without a reliable internet connection. So, all the invoices etc. are linked to the GUID and not the customer ID, making it possible to later merge all the data into a single database, without running the risk of having things get linked to each other the wrong way.
You are correct in your statements that the unique identifiers should have been enough, but think about what would happen if you had multiple databases running at the same time. You could end up with five customers, each having customer ID 4, for example. If I were to make a guess, I’d say this is why the original designers went this route.