Currently, I have a
categories table with 2 columns -
category VARCHAR(50) NOT NULL PRIMARY KEY and
parent VARCHAR(50). The
parent column is a foreign key (FK) to the
This seems like the most obvious approach. However, alarm bells are ringing in my head because I am using a
VARCHAR column for a primary key, which might slow down operations when querying the table.
I could introduce a third column called
cat_id INT AUTO_INCREMENT and set that to be the PK, but it would introduce a new column which have no meaning.
Apart from which one would be faster, what other considerations should be taken?
N.B. I predict there will be at most 1000 categories or so so the number of rows are not very high. However, the
categories PK column will be a reference column for many foreign keys, in other tables.
Should I use (unique) usernames as PK's also?