My problem is that nature key and auto_increment integer as primary key.
For example, I have tables A and B and A_B_relation . A and B can be some objects, and A_B_realtion record the relationship of many, many of A and B.
Both A and B have their own global unique identifier, such as a UUID. The UUID is available to the user, which means that the user can request A or B by UUID.
There are two ways to create a primary key for a table.
- use the integer auto_increment.
A_B_relation specify the integer as FK. - use UUID.
A_B_relation refers to the UUID as FK.
For example, a user wants to request all associated data B from A to UUID.
In the first case, the request flow is as follows:
First, query A integer primary key by UUID from `A`. And then, query all the B integer primary key from `A_B_relation`. At last, query all the B info from `B`.
In the latter case, the stream is as follows:
Query all the B UUID from the `A_B_relation` by A UUID. Query all the B info from `B`.
So, I think the latter case is more convenient. It is right? what is the disadvantage of the latter case?
source share