Laravel's pivot table + Pivot table in general

后端 未结 4 1746

What are laravel pivot tables and pivot tables in general? What is this all about?

Recently I made research about Pivot table. I thought I know them and What they are bu

4条回答
  •  臣服心动
    2021-02-12 21:03

    Simply put is a pivot table a table that joins two tables together

    say you have a table users

    USERS:
    user_id, user_name
    

    say you have a table games

    GAMES
    game_id, game_name
    

    a user can play many games. games have many users playing them.

    To link them you make a third table

    GAMES_TO_USERS
    game_id, user_id
    

    with this table you can request which games a user plays, and which users play which game.

    this table GAMES_TO_USERS is in this case the pivot table.

提交回复
热议问题