This is a user table associated with the Group table uid,group_id is the only pair.
"Scenario 1: (unique) composite Index"
UNIQUE KEY uid_group_id (uid,group_id)
"Scenario 2: Composite primary Key"
PRIMARY KEY (uid,group_id)
1: I hope the great God can combine this example to explain which kind of scheme is better, and similarities and differences.
2: The first way specific name how to call Ah, still do not know?
Thanks, ^_^.
Reply content:
This is a user table associated with the Group table uid,group_id is the only pair.
"Scenario 1: (unique) composite Index"
UNIQUE KEY uid_group_id (uid,group_id)
"Scenario 2: Composite primary Key"
PRIMARY KEY (uid,group_id)
1: I hope the great God can combine this example to explain which kind of scheme is better, and similarities and differences.
2: The first way specific name how to call Ah, still do not know?
Thanks, ^_^.
If the two fields are incremented, use the primary key to conform to the index, and if not all increment it with a unique one.
But in fact, no matter how the table structure design is very strange.
Call it random, I think the only compound index on the line, as long as others understand it.