Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Implementing Surrogate Key Expand / Collapse
Author
Message
Posted Thursday, August 2, 2012 3:49 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 3:05 AM
Points: 255, Visits: 620
How to implement surrogate key ?
Post #1339037
Posted Thursday, August 2, 2012 6:35 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:33 AM
Points: 7,178, Visits: 13,630
shahsn11 (8/2/2012)
How to implement surrogate key ?


CREATE TABLE MyTable (
MyTableID INT IDENTITY(1,1) PRIMARY KEY,
.
.
.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1339095
Posted Thursday, August 2, 2012 7:08 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 3:05 AM
Points: 255, Visits: 620
So does that mean that Surrogate Key is only the concept. And in lay man terms(i.e. mine) can we say that PK=Surrogate Key.

If the above is true that what is the difference between Pk and surrogate key.
Post #1339128
Posted Thursday, August 2, 2012 7:18 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:18 AM
Points: 13,553, Visits: 10,429
shahsn11 (8/2/2012)
So does that mean that Surrogate Key is only the concept. And in lay man terms(i.e. mine) can we say that PK=Surrogate Key.

If the above is true that what is the difference between Pk and surrogate key.


A surrogate key is by defination meaningless, aka a simple integer with no meaning attached which serves as a primary key. A primary key is a combination of one or more columns that uniquely identify a row. So it's possible this is for example a customerID, such as AW001578. This has meaning, as it is customer number 1578 of the Adventure Works company. Or it can be an emailaddress to uniquely identify a person. This is often called the "natural key".

So, a surrogate key is a primary key, but a primary key is not necessarily a surrogate key.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1339139
Posted Thursday, August 2, 2012 7:25 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:33 AM
Points: 7,178, Visits: 13,630
shahsn11 (8/2/2012)
So does that mean that Surrogate Key is only the concept. And in lay man terms(i.e. mine) can we say that PK=Surrogate Key.

If the above is true that what is the difference between Pk and surrogate key.


A PK is a means of uniquely identifying a row. It's either an attribute(s) of the data (natural key), or it can be generated by the RDBMS (surrogate key). Here's a nice article to get you started.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1339149
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse