I want to use SQL statements on insert to insert the new / next identifier value for my Primary Unique Index while being able to support joins with PK and FK relationships> What is the simplest solution? Data type/length recommendation? The data is reference, operational and technical metadata relatively lower volumes to transactional data.
Asked
Active
Viewed 29 times
-3
-
Do you mean Primary key by "primary unique index" ? – Mehrad Eslami Jun 28 '17 at 19:13
-
Nobody can provide an answer here because there isn't a question. Simplest is not something you should every worry about, the ease of the developer is not important. It is about a solid data model that will allow for performant queries. The datatype would depend on what the key is. – Sean Lange Jun 28 '17 at 19:15
-
1Your question is not clear. – Tab Alleman Jun 28 '17 at 19:20
-
Agree I degressed and went to the dark side – user7347640 Jun 29 '17 at 21:14
1 Answers
0
Without knowing your data needs, I would use an INT for the primary key as you state this is relatively lower volumes of transactional data. INT supports -2,147,483,648 to 2,147,483,647. As I would use an auto incrementing integer beginning at 1 as the primary key, if you plan to have more than 2 billion rows then use a big int which supports up to 9,223,372,036,854,775,807. This will automatically populate your primary key.

Andrew O'Brien
- 1,793
- 1
- 12
- 24
-
Thank You. I decided to go with an int identity vs a guid or some other value. I also realized my insert into did not need to declare the identity field – user7347640 Jun 29 '17 at 21:16