Thursday, March 9, 2017

Foreign key and index

Is there any difference between

$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

and

$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

For me it's the same because foreign key is an index, am I right ?



via Neabfi

Advertisement