# Laravel database schema with foreign key when creating a foreign key for laravel, the target column must be unique example ```php /* referenced table */ id()->autoIncrement(); $table->integer("roles_member_role_id"); $table->foreign("roles_member_role_id") ->references('role_id') ->on('roles_member'); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('roles'); } }; ``` then the table (that we reference it) ```php id(); $table->integer("role_id")->unique(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('roles_member'); } }; ```