Someone recently suggested that I remove an auto incrementing table used solely for storing IDs. I have not yet gone with this, I'm just exploring whether it is in fact a better solution than what I currently have. This would leave me with a table like this:
create table tag_translations (
tag_id int not null,
language_id int not null,
tag_name varchar(255),
primary key (tag_id, language_id)
);
I'm going to have duplicates for tag_id, storing translations of the tag in other languages.
When adding new tags, I need to forgo using auto increment on the tag_id, and instead assign new ID's manually. Unless it's just a translation of an existing tag, the ID needs to be unique for the new batch of translated inserts.
Can someone explain to me, in plain English, how this is typically done? I thought on this, but it doesn't seem to be any cleaner than my previous approach, if I have the thinking right. Here's what I'm assuming the process is:
- Select tag_id from tag_translations
- Pick the highest number in the result set + 1
- Make a new query (for insertion)
- Define some additional strategy for ensuring that ids for new tag_id records are never duplicated when tags get created at more or less the same microsecond
If this is the process, I think I'm better off sticking with my existing schema of having an additional table to auto increment ids. I still have to do an additional query to first check for a unique id (I'm trading a single join down the road for an insert today). If the headache of keeping my IDs unique when they need to be unique is what I think it will be, I may want to abandon this approach and stick with what I've got. Is my thinking sound?