我有這個學校的學生數據庫。比方說,例如,一名學生的學生證是098-123-123。我希望那個學號是主鍵。建議使用字符串而不是增量?我是否需要更改表格的結構並更改laravel中的默認增量('id')?這裏最好的做法是什麼?我是否需要將學生ID定義爲主鍵並更改laravel中雄辯orm的默認ID?
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('privillege');
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
最佳做法是將主鍵保留爲「增量」。你可以爲學號添加另一列,並將其設置爲「唯一」。例如:'$ table-> string('student_number') - > unique();' – smartrahat