2

Right now, I am designing the database as you all know, primary keys are important factor in the database design.

I have dilemma in deciding the primary key between GUID, identity (Auto Increment) and a custom key for primary key, in which scenario should I use?

I am trying to database design for school. School has many branches in the different location and different cities. school have central database, they want to update every day at evening.

Please guide me? Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

2

In my opinion, the default choice is to use a 32-bit integer with auto-increment.

You might use GUID under specific scenarios that are covered in this QA: What are the best practices for using a GUID as a primary key, specifically regarding performance?

A custom key should only be used if you need to assign a specific key for some reason based on your design or based on business requirements.

Edit: Based on your update, if you are merging disconnected tables you might want to consider using GUID keys so you don't have problems with collisions.

Community
  • 1
  • 1
pseudocoder
  • 4,314
  • 2
  • 25
  • 40
0

I suggest you to choose identity (Auto Increment) because when you use custom primary key you should generate an random number and then save it. when identity (Auto Increment) don't need. and when you use GUID sql or you have to generate a GUID and then store it. identity (Auto Increment) is more general and easy to understand too.

Mohamad Shiralizadeh
  • 8,329
  • 6
  • 58
  • 93