N
N
NDll2022-03-16 13:42:10
MySQL
NDll, 2022-03-16 13:42:10

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();
        });


how to properly implement a table so that you can moderate the image of the news?

thought to create a table where the pictures of the news will be stored

article_images
-id
-article_id
-path
-image
-is_moderated
-created_at


but when selecting news, you will have to make an additional request to display the news image. What do you suggest?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-03-16
@Akela_wolf

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 question

Ask a Question

731 491 924 answers to any question