Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you have 2 foreign keys and no primary key?

I have a simple database and I'm making a relationship between two tables. So I have this 3rd table where they are linked. Does the third table require a primary key? Because all I need in it is to link the two tables together and an extra column for something else.

like image 519
Tom Avatar asked Nov 22 '12 18:11

Tom


1 Answers

The kind of table you're describing is sometimes called a join table. You would create a primary key across the columns you're joining, both for uniqueness and because it's more likely to be indexed for better performance.

like image 182
Chris Jester-Young Avatar answered Sep 21 '22 14:09

Chris Jester-Young