Naming convention for join tables, in a many to many relationship, in Laravel

Yahya Uddin

I have 3 tables.

The first two tables are Groups and Accounts.

  • An account can belong to many groups.

  • A group can have many accounts.

  • In other words it is a many to many relationship.

Therefore I need a 3rd table, which is a join table

What is the recommended naming convention of this join table in Laravel (or perhaps in general).

Is there any naming conventions?

I was planning to call it "GroupsAccountAssignment".

jaysingkar

The name of the pivot table should be account_group.

As given in laravel docs

To define this relationship, three database tables are needed: users, roles, and role_user. The role_user table is derived from the alphabetical order of the related model names, and contains the user_id and role_id columns.

Though, you can always overwrite the default naming convention like below:
Account Model:

return $this->belongsToMany('App\Group', 'GroupsAccountAssignment', 'account_id', 'group_id');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

naming tables in many to many relationships laravel

From Dev

How to JOIN tables in many-to-many relationship

From Dev

Laravel Complicated inner join on many to many relationship

From Dev

Naming convention when same type of field is in many tables?

From Dev

Join Postgresql Tables with naming convention

From Dev

Join EF code first many to many relationship tables

From Dev

EF6 Many to Many relationship, multiple tables to join table

From Dev

Laravel - Many to Many relationship

From Dev

Many to many relationship in Laravel

From Dev

Many to Many relationship with Laravel

From Dev

Many to many Laravel Eloquent relationship with multiple intermediate tables

From Dev

Laravel: Add a join to self referencing Many-to-Many relationship?

From Dev

Laravel 6 many to many relationship

From Dev

Pagination with many to many relationship in laravel

From Dev

Laravel many to many relationship error

From Dev

Laravel many to many relationship with conditions

From Dev

Laravel ORM many to many relationship

From Dev

How to change the naming convention of Many-to-Many table relationships?

From Dev

Laravel: one to many relationship

From Dev

one to many relationship in laravel

From Dev

Many to Many Relationship over multiple tables

From Dev

Joining two tables with many to many relationship in sql

From Dev

Many to Many Relationship over multiple tables

From Dev

Entity Framework with many to many relationship generetad tables

From Dev

Joining two tables with many to many relationship in sql

From Dev

Inserting a has many relationship tables at the same time in laravel

From Dev

Laravel eloquent one to many relationship in custom pivot tables

From Dev

JPQL left outer join on many to many relationship

From Dev

Oracle Recursive Join - Many to Many Relationship

Related Related

  1. 1

    naming tables in many to many relationships laravel

  2. 2

    How to JOIN tables in many-to-many relationship

  3. 3

    Laravel Complicated inner join on many to many relationship

  4. 4

    Naming convention when same type of field is in many tables?

  5. 5

    Join Postgresql Tables with naming convention

  6. 6

    Join EF code first many to many relationship tables

  7. 7

    EF6 Many to Many relationship, multiple tables to join table

  8. 8

    Laravel - Many to Many relationship

  9. 9

    Many to many relationship in Laravel

  10. 10

    Many to Many relationship with Laravel

  11. 11

    Many to many Laravel Eloquent relationship with multiple intermediate tables

  12. 12

    Laravel: Add a join to self referencing Many-to-Many relationship?

  13. 13

    Laravel 6 many to many relationship

  14. 14

    Pagination with many to many relationship in laravel

  15. 15

    Laravel many to many relationship error

  16. 16

    Laravel many to many relationship with conditions

  17. 17

    Laravel ORM many to many relationship

  18. 18

    How to change the naming convention of Many-to-Many table relationships?

  19. 19

    Laravel: one to many relationship

  20. 20

    one to many relationship in laravel

  21. 21

    Many to Many Relationship over multiple tables

  22. 22

    Joining two tables with many to many relationship in sql

  23. 23

    Many to Many Relationship over multiple tables

  24. 24

    Entity Framework with many to many relationship generetad tables

  25. 25

    Joining two tables with many to many relationship in sql

  26. 26

    Inserting a has many relationship tables at the same time in laravel

  27. 27

    Laravel eloquent one to many relationship in custom pivot tables

  28. 28

    JPQL left outer join on many to many relationship

  29. 29

    Oracle Recursive Join - Many to Many Relationship

HotTag

Archive