How to record likes and display likes and nos in youtube?

how do you design database fields like youtube pages that show whether you have pressed like or dislike? And go to the database to judge when the user arrives at the page?

whether the design idea is like this

Post table
id picroute likeusers dislikeusers
1 img/0001.jpeg {1, 3, 4, 6, 11, 44, 233} {2, 5, 8, 15, 6, 7, 7, 88}

put it in a field to click like"s userid

Can you tell me what syntax does the separator-like method use to fill in the end of the field one by one?

is it possible to read the reality in the database processing syntax, for example, whether likeusers has 11 userid without having to take the entire likerusers field out of the database and then use something like sieve ringworm for php or javascript processing?

in addition, can I use sql syntax to add and delete a userid that is not the whole field and delete it after the whole field is removed? use the update to put the field back in the whole field?

some people may want to say why I don"t consider the whole table, but I think it"s too much table for an youtube article with a like dislike to create a table to accommodate the userid that has been clicked on like.

so the effect you want to achieve is

there are multiple pictures on one page, for example, nine pictures
each picture has a like and dislike button and a display number

when the user enters this page, the database takes out the connection src of each picture, and then compares the user"s userid to whether there is the userid in the userlike array of a single id in each post table

.

if likeusers has the userid, it shows that like cannot be clicked, but dislike can click
and vice versa
and then if both fields do not have userid, then both like and dislike show selectable states

do not know that such a design concept is OK? Or is there any way to achieve it?
I want to know and write it out with laravel, but I still don"t know what sql syntax can be used
to write userid to the same field or to check whether there is the userid in the same field and how to delete and add a userid? individually

Mar.02,2021

it is recommended to familiarize yourself with the documentation first. It is very easy to achieve similar requirements in laravel, just use many-to-many associations.
first build the corresponding model and table:
User model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    //
}

users

Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
    $table->string('username')->unique()->nullable();
    $table->string('password')->nullable();
    $table->rememberToken();
    $table->timestamps();
});

Post model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //
}

posts

Schema::create('posts', function (Blueprint $table) {
    $table->increments('id');
    $table->unsignedInteger('user_id')->index();
    $table->string('path');

    $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
    $table->timestamps();
});

then add the corresponding association to the model. As mentioned earlier, likes are suitable for many-to-many associations
User model

.
public function likes(){
    return $this->belongsToMnay('App\Models\Post');
}

Post model

public function liked_users(){
    return $this->belongsToMany('App\Models\User');
}

at this time, all you have to do in the controller is to call the following method:

// 
$user->likes()->attach($post_id);
// 
$user->likes()->detach($post_id);
// 
$user->likes;
// 
$user->likes()->paginate(10);
// 
$user->likes()->where('post_id',$post_id)->exists();
// 
$post->liked_users;

for more information on the use of many-to-many, please see the documentation
https://laravel-china.org/doc.

.
Is

the function of voting and opposing like sf? If I were to do it, I would do it like this:

id     article_id user_id   is_like
ID   ID     ID    (10)

as above is the data structure of the table, it should meet your functional requirements;
and the value and query are also convenient;

It is not clear how to operate in

laravel, but if your fields have to store the data structure of 1, 3, 4, 5 , then the native mysql can be operated with the find_in_set function;

Isn't

all implemented with Redis ? The INCR command of
Redis is used to do exactly this.

Menu