I am trying to do something like this: "DELETE FROM User WHERE user_name_surname ='user_02'"
I dont really know how to explain my problem so ill write a sequence of things that should explain my problem: - i create a new user - user_01 - i create a new group - group_01 - i assign user_01 to group_01 (User with Membership tables) - i create a new message with user_01 (Message table) - i send this message to group_01 (Group_messages table)
Heres where the problem appears: - i create a new user - user_02 - i assign this user to already existing group - group_01 - i try to delete this user but i cant because group_01 is linked with Group_messages table
So yeah, can i somehow 'unlink' the user from group?
you need to first check for use references in membership and Message tables (Message,Single_messages). First delete them from those tables before you delete the user.
Another way to deal with it is to create foreignkeys with on delete cascade option so that when you delete a user the reference records will also get deleted from other table. But this is NOT RECOMMENDED as without proper documentation this can be a pain to maintain and support.