Should I create a role for every user?
I seem to understand that for every user with "uid" = "userID", you want to create 1 role like "role_userId" ... That means if you have dozens of users (only), you have dozens of roles. Not to mention that you have hundreds (or thousands?) of users if you'd have hundreds (or thousands?) of roles ... IMO that is not a good idea. I'm not sure what exactly you're up to with that "user view some fields which are public and others can only see friends (user relationship or flag friend, ...)", as in your question, but it does seem to be related to access permission somehow.

Have a look at the Group module, which allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. The Group module creates groups as entities, making them fully fieldable, extensible and exportable.

In your case you could have 1 Group "Type" (eg: "User Groups"?), and create 1 group for each user. Think of a Group Type as equivalent to a Content Type, and a Group (of a specific Group type) as equivalent to a node of a specific Content Type). You'd probably come close to having something with a 1-to-1 relationship between a specific user and Group permissions related to that user (whereas Group permissions is not the same as standard Drupal permissions ...).

Also, since Group is fully entity based, it integrates perfectly with Rules also. With that in mind, you could use Rules to capture Rules Events about user relationship or flag friend (as in your question), and then trigger Rules Actions to manage various access levels to the Group designated to that user. Important to realize: you wouldn't need like dozens (or hundreds/thousands?) of "roles".

For more details about the various roles and permissions, refer to my answer to "What are the various roles supported by the Group module?".

Resources


Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".