Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use primary key or unique index for tag names?

I'm just wondering that, if I implemented a tags system, should I use a primary key on the tag name, or just have the usual primary key with a unique index on the tag name column?


1 Answers

Assuming the tag entity will be used in millions of rows, a numeric column will perform better than a string as a foreign key column. This is why you use surrogate keys

So "just have the usual primary key with a unique index on the tag name column"

like image 191
gbn Avatar answered Dec 02 '25 13:12

gbn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!