Hello.
I have some troubles on database relationships.
Let me explain shortly:
I have created two tables as Users and Phones.
Phones model has several columns such as phone_type, phone_name, phone_number and etc.
A user can have several phones.
So I think the relationship between Users and Phones is 1:N and then I have set the relation line according to my idea.
But it doesn’t work right now.
If I changed the phones model data, it reflects in all users.
Could you provide me some good advice?
Then hope to let me know how to make these two models and set the relationship?
As I mentioned, Role:Main Permission is 1:N, and Main Permission:Sub Permission is also 1:N.
And each role has all main permission s and also each main permission has all sub permissions.
The trouble is when I change the main permission data, it reflects in all roles in role table.
In this case, sub permissions are also same as above.
Hi.
Then what I want is that each role has different main permissions.
I am sure my relationship is not right.
But I don’t know how to do it what I want.
I mean, each role has different main permissions and when I change the one role’s main permission data, it is not needed to reflect to another role.
Hope to hear from you best solution.
Thanks again.
I mean, each role has different main permissions and when I change the one role’s main permission data, it is not needed to reflect to another role.
In that case, you should reorganize your table in a way, where Main Permission - it’s just a flag record, without any data. You could move that data to the Roles Table, or maybe another table and Roles table will rely on it.
OR
You could duplicate every permission that requires different data.
But they are in the same table. They can’t rely on each other.
Referring to your screenshots I guess that you need to reorganize the schema. But I still can’t catch which data is different between the permissions with the same type.
Let’s assume that role table has two object “X, Y” and the main_permission table has three object “A, B, C”.
Sub_permission table has also three object “1, 2, 3”.
The objects of role table has all objects of main_permissions table.
( I mean “X” has “A, B, C” and also “Y” has “A, B, C” )
The main and sub_permission table has also same relationship.
What I want is that if I change the permission table’s value to “B, C, D”, then it is only reflected to role X, not Y.
If you think I created the table schema wrong, please let me know the sample schema to implement my idea.
It’s a little urgent so I am asking for your help.
What I want is that if I change the permission table’s value to “B, C, D”, then it is only reflected to role X, not Y.
has also same relationship and only reflected to role X - points that couldn’t exist at the same time.
You describe entity Permission, but it doesn’t look like permission at all, because you change it and they are not common(the reason of it - you don’t want “reflection”).
There are a lot of ways to solve your problem like:
doesn’t use relations but uses some string keys and additional find by this key
or make a bunch of “permissions” for every role that will look the same, but exist independently.
or make a correct schema where permission is real permission, consistent, and common for everybody.
All those things could or couldn’t fit your business logic, and I can’t say which one you should use.
As for:
It’s a little urgent so I am asking for your help.
and
Please send me the best solution to fix it.
Please, take into account that this forum was created to help our user with their issues related to Backendless. In your case, it’s not a bug or even a Backendless-related issue.
If you want to get help with your business logic, you could contact sales@backendless.com