Drawbacks natural key eloquent?
For an application I'm building which tracks training (for a sport), I am designing the database tables. And important table is the 'trainings' table, which at the moment is created with:
Schema::create('trainings', function(Blueprint $table)
{
$table->increments('id');
$table->date('date');
$table->string('activity', 255);
$table->smallInteger('time');
$table->enum('intensity', array('1', '2', '3', '4', '5'));
$table->text('details')->nullable();
$table->integer('user_id')->unsigned();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
However, I want to allow users to add their own 'activities' in the application. So there will be a table 'Activities'. I can of course go the default route of using a surrogate primary key 'id' together with a table field 'name' or 'activity'. Like:
Schema::create('activities', function(Blueprint $table)
{
$table->increments('id');
$table->string('name', 255);
$table->timestamps();
});
But if I make the column 'activity' the primary key, I can ditch the surrogate id key. Which has the added benefit of making the data in the trainings table more readable and easier to query (a join less when selecting trainings).
Are there any drawbacks with using a natural key in this key, maybe specific to using Laravel?
Please or to participate in this conversation.