Using Firebase User UIDs for keys of related DB entries - Good or Bad Practice?

Isaac Gregson

Are there any problems with using a user's UID (which is generated by Firebase upon user creation via Firebase Auth) as the key for associated database entries?

For example, here:

/config/user.uid/configObject

...each user has one config entry. Due to Firebase's database rules (where settings on a parent node apply to all child nodes) it's often necessary to create a separate config tree (following the example, where a /users tree needs to be read and write protected).

The only reason I can see that this might be bad practice is if the user's UID ever changes... Does Firebase guarantee that this will never happen? Anything I'm missing?

whatsthatitspat

The UID for a particular user will never change (though they did change the format a few months ago; the old format included the provider).

It's a good practice, a necessary one in many cases, and probably recommended somewhere. You'll want to denormalize user info into multiple nodes for better performance and for authorization as you mentioned. It might look something like this in pseudo code/rules:

- users_private (.read: $uid == auth.uid)
  - $uid
    - email

- users_public (.read: true)
  - $uid
    - name
    - photo

- users_roles (.read: dependent on some other rules)
  - $uid
    - is_admin
    - is_editor

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Nullable foreign keys - good or bad practice?

From Dev

Is it good or bad practice to have multiple foreign keys in a single table, when the other tables can be connected using joins?

From Dev

Using if statement inside if statement, good or bad practice?

From Dev

Is it bad practice to store obsolete authorized_keys as user/group nobody?

From Dev

Is using type as dictionary keys considered good practice in Python?

From Dev

Is getOrCreate function a good or a bad practice?

From Dev

Good or bad practice? Redirecting to stderr?

From Dev

Composite Primary Keys : is it good or bad

From Dev

good practice in MySQL DB structure

From Dev

Using position is good practice or not

From Dev

"Container" classes, good or bad practice, why?

From Java

The Use of Multiple JFrames: Good or Bad Practice?

From Dev

Vim Plugins: EasyMotion - Good or bad practice?

From Dev

HTML Good or Bad Practice to Uniquely Identified Elements

From Dev

PHP Classes load() method good/bad practice?

From Dev

PHP array to object good or bad practice

From Dev

PHP arrays and objects together - Bad / Good Practice?

From Dev

HTML Good or Bad Practice to Uniquely Identified Elements

From Dev

angularjs using angular.extend to bind $scope to a service bad/good practice

From Dev

Static data in firebase is a bad practice?

From Dev

Code-Design good practice bad practice of interfaces

From Dev

What is a good way to change a group of users UIDs without usermod executing a time consuming chown on the user home directory?

From Dev

Is it good or bad to store the DB connection details with define()?

From Dev

Good Practice of using ThreadLocal in Java

From Dev

Is "using std::begin;" a good practice?

From Dev

Is "using std::begin;" a good practice?

From Dev

When is using reflection a good practice?

From Dev

Storing HTML in Firebase (AngularFire), good idea or bad?

From Dev

Storing User Data in the $rootScope - Good or Bad?

Related Related

  1. 1

    Nullable foreign keys - good or bad practice?

  2. 2

    Is it good or bad practice to have multiple foreign keys in a single table, when the other tables can be connected using joins?

  3. 3

    Using if statement inside if statement, good or bad practice?

  4. 4

    Is it bad practice to store obsolete authorized_keys as user/group nobody?

  5. 5

    Is using type as dictionary keys considered good practice in Python?

  6. 6

    Is getOrCreate function a good or a bad practice?

  7. 7

    Good or bad practice? Redirecting to stderr?

  8. 8

    Composite Primary Keys : is it good or bad

  9. 9

    good practice in MySQL DB structure

  10. 10

    Using position is good practice or not

  11. 11

    "Container" classes, good or bad practice, why?

  12. 12

    The Use of Multiple JFrames: Good or Bad Practice?

  13. 13

    Vim Plugins: EasyMotion - Good or bad practice?

  14. 14

    HTML Good or Bad Practice to Uniquely Identified Elements

  15. 15

    PHP Classes load() method good/bad practice?

  16. 16

    PHP array to object good or bad practice

  17. 17

    PHP arrays and objects together - Bad / Good Practice?

  18. 18

    HTML Good or Bad Practice to Uniquely Identified Elements

  19. 19

    angularjs using angular.extend to bind $scope to a service bad/good practice

  20. 20

    Static data in firebase is a bad practice?

  21. 21

    Code-Design good practice bad practice of interfaces

  22. 22

    What is a good way to change a group of users UIDs without usermod executing a time consuming chown on the user home directory?

  23. 23

    Is it good or bad to store the DB connection details with define()?

  24. 24

    Good Practice of using ThreadLocal in Java

  25. 25

    Is "using std::begin;" a good practice?

  26. 26

    Is "using std::begin;" a good practice?

  27. 27

    When is using reflection a good practice?

  28. 28

    Storing HTML in Firebase (AngularFire), good idea or bad?

  29. 29

    Storing User Data in the $rootScope - Good or Bad?

HotTag

Archive