Solved

Are you supposed to apply the primary key to an IDENTITY column? Please elaborate.

Posted on 2013-02-07
2
221 Views
Last Modified: 2013-02-07
When creating  an IDENTITY column in  a table do you also apply a primary key to it?


Example:
CREATE TABLE HR.Employees(
EmployeeId INT IDENTITY(1000 ,2) NOT NULL
,etc…)
0
Comment
Question by:rhservan
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 38865555
Identity fields are almost always primary keys yes, as it guarantees uniqueness in a row, but it is not required.

In your above T-SQL, making EmployeID the identity field might not always work, if the client sees a scenario where they would want to manually change the id for whatever reason.   If that's the case, an identity field would be the primary key, the actual EmployeeID would be what's called a 'business key'.  Forms would always display business key, and the database is related via the identity field.

You'll have to feel them out on that one.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38865687
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now