I am trying to figure out how to do a table with 3 columns:
unique_id, type, version
Where unique_id is AUTO_INCREMENT for each record, and version is AUTO_INCREMENT for each type.
The purpose being, when I insert I only have to specify ‘type’ and the unique_id and version_id are automatically generated. eg:
insert type 'a', then values are: 1 , a , 1
insert type 'a', then values are: 2 , a , 2
insert type 'a', then values are: 3 , a , 3
insert type 'b', then values are: 4 , b , 1
insert type 'b', then values are: 5 , b , 2
insert type 'a', then values are: 6 , a , 4
Also would it be fair to say that such a setup is not really normalised? That instead it should be two tables?
You can’t have auto-generated sequences for each type, but you can generate your own.