Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consensus? MySQL, Signed VS Unsigned Primary/Foreign Keys

I have seen a couple threads about what everyone was doing now a days in regards to signed vs unsigned key values. It would seem that unsigned is optimal since it allows twice the number of rows for the same cost. Are there any benefits with signed keys?

Is there any standard consensus? Its seems like signed is the answer since "it has always been that way"

like image 960
Parris Avatar asked Jun 28 '10 23:06

Parris


1 Answers

I prefer to set my columns as unsigned if they cannot be negative. Besides the range factor that you mentioned, it also makes it clearer when reading the table definition.

like image 89
Daniel Egeberg Avatar answered Sep 27 '22 21:09

Daniel Egeberg