Skip to main content

role_permission

Table Name: role_permission

The role_permission table is used to create a many-to-many relationship between the role and permission tables. This table allows each role to have multiple permissions and vice versa.


Columns

Column NameData TypeConstraintsDescription
roleIdsmallint(6)Primary Key, Not Null, Foreign KeyThe unique identifier of the role. This links to the role table.
permissionIdsmallint(6)Primary Key, Not Null, Foreign KeyThe unique identifier of the permission. This links to the permission table.

Indexes

  1. Primary Key:
    • roleId, permissionId: Uniquely identifies each combination of roleId and permissionId. This ensures that a role can only have a specific permission once.
  2. Foreign Keys:
    • FKBD40D53895E72B9E:
      • Referenced Table: permission
      • Referenced Column: permissionId
      • Description: Ensures that the permissionId exists in the permission table, linking the permission to the role.
    • FKBD40D538C344B2EC:
      • Referenced Table: role
      • Referenced Column: roleId
      • Description: Ensures that the roleId exists in the role table, linking the permission to the role.

Foreign Key Relations

  1. FKBD40D53895E72B9E:
    • Referenced Table: permission
    • Referenced Column: permissionId
    • Description: Ensures that each permissionId in the role_permission table corresponds to a valid permissionId in the permission table, maintaining the relationship between roles and permissions.
  2. FKBD40D538C344B2EC:
    • Referenced Table: role
    • Referenced Column: roleId
    • Description: Ensures that each roleId in the role_permission table corresponds to a valid roleId in the role table, linking permissions to roles.

Usage Notes

  • Purpose:
    • This table creates a many-to-many relationship between roles and permissions, enabling roles to have multiple permissions and permissions to be associated with multiple roles.
  • Key Attributes:
    • roleId: The ID of the role from the role table.
    • permissionId: The ID of the permission from the permission table.