Answer the question
In order to leave comments, you need to log in
How to properly implement mysql table structure?
Hello!
There are tables for articles
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('city_id');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('retail_id');
$table->foreign('retail_id')
->references('id')->on('retails')
->onDelete('cascade');
$table->string('image');
$table->string('title');
$table->text('description');
$table->mediumText('text');
$table->string('meta_title');
$table->text('meta_description');
$table->string('slug')->unique();
$table->boolean('is_published')->default(true);
$table->boolean('is_moderated')->default(false);
$table->bigInteger('count_likes')->default(0);
$table->bigInteger('count_shares')->default(0);
$table->bigInteger('count_views')->default(0);
$table->softDeletes();
$table->timestamps();
});
article_images
-id
-article_id
-path
-image
-is_moderated
-created_at
Answer the question
In order to leave comments, you need to log in
If the news has one picture, you can put it directly into the news table (by the way, is only the picture moderated? Does the news itself not pass moderation?)
If the news has several pictures, put it into a separate table. Well, there will be a separate query, it will work quickly by index, there is nothing wrong with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question