لا تستخدم UUID كـ Primary Key

لا تستخدم UUID كـ Primary Key

2024-05-15 وقت القراءه : 1 دقائق

Bad Practice Example

Schema::create('tasks', function (Blueprint $table) {
    $table->uuid('uuid')->primary();
    $table->string('description');
    // ...
});

What To Do Instead

Schema::create('tasks', function (Blueprint $table) {
    $table->id();
    $table->uuid('uuid');
    $table->string('description');
    // ...
});

ال uuid هو رابط بهذا الشكل 116c34de-3dcb-44bc-9511-a48242b9aaab يستخدم عادة لإخفاء الـ id=9 ، لكن إستخدامة ك primary key قد يسبب بعض البطئ..، مما يؤثر على الأداء، فمن المفضل الإبقاء على حقل id.

إضافة تعليق
Loading...