I have a table Tags which has 2 columns:
name VARCHAR(50)
group_id INT
The combination on both cannot be repeated so I use a composite key to make sure that the combination of name and group_id cannot be used 2 times.
But since the name is a varchar column, it is not a very good option for querying the database, so if I use an id column which is not a primary key but is an autoincrement, I can search for only one column in the database will be ok?
The table will be like this:
name VARCHAR(50) PRIMARY KEY,
group_id INT PRIMARY KEY
id autoincrement NOT NULL
I never seen this before and it looks like a solution, but I really need other point of view before applying this solution.
i have to import the tags from a file and those tags have a many many relation with another table that i'm also importing from the file, just to ilustrate the file structure is like this:
enterprises |TagGroup1 |TagGroup2 |...TagGroupN Google |t1.1,t1.2 |t2.1,t2.2 |tN.1,tN.2 canonical |t1.1.1 |t2.1,t2.2 |tN.1,tN.2
given this file i'll explain that a tag belongs to a group and an enterprise has tags so when i import the file i import the group and then create the tags in bulk, them import enterprises but when i need to import the relation between tags and enterprises if i have need the tag numeric id that will force me to insert the tags one by one wich is not a good idea at all, but if i had the name and group ID as key i not longer need to wait for the tag's ID...
sorry this is to long and i'm triying to explain my problem but i don't know if i succeded in making this simple to understand