Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tayyabshahzad1's avatar

Update or Detete

Hi, I have a scenario in my application and that is. Tables Permissions | Permission Group | Assigned Permissions 1 - Permissions I have simply listed all permissions e.g permission name (Create User) 2- Permission Group In this table, I have 2 columns one permission JSON column and the second group_name column where I am storing all group names like Suppliers, sellers, etc the second column I am storing data in JSON which is all permissions that will be assigned to the new group. 3 - Assigned Permissions Here I am storing user_id, permission_id and group_id

Now I want when the ``Permission Group tableto update the related data which is in theAssigned Permissionstable will update For example, I have group nameAdminwith permission 1 , 2 3 , if I add groupAdminto userAsystem will store 1,2,3permissionsin theAssigned Permissions table, Now If a user updates the group and attach new permession from 1,2,3 to 8,5,6 then Assigned permission table` will update and remove permission 1,2,3 and create a new record which is 8,5,6 how can I do this I hope this is understandable :)

0 likes
2 replies
Tray2's avatar

No it is not understandable.

  1. Don't use json in your database
  2. Don't use json in your database
  3. Don't use json in your database.
  4. Read this post to understand why, and how to do it properly. https://tray2.se/posts/database-design

For some more good advice and database knowledge give these a read as well.

https://tray2.se/posts/database-design-part-2 https://tray2.se/posts/sqlerrm https://tray2.se/posts/properly-formed-foreign-keys-are-your-best-friends

2 likes

Please or to participate in this conversation.