Auto Increment Composite Key InnoDB
Ich möchte ein MyISAM-ähnliches Verhalten für eine InnoDB MySQL-Tabelle erstellen. Ich möchte einen zusammengesetzten Primärschlüssel haben:
PRIMÄRSCHLÜSSEL (ID1, ID2)
Wobei id1 automatisch anhand des Werts von id2 inkrementiert wird. Was ist der beste Weg, um dies mit InnoDB zu erreichen?
+----------+-------------+--------------+
| id1 | id2 | other_column |
+----------+-------------+--------------+
| 1 | 1 | Foo |
| 1 | 2 | Bar |
| 1 | 3 | Bam |
| 2 | 1 | Baz |
| 2 | 2 | Zam |
| 3 | 1 | Zoo |
+----------+-------------+--------------+