# Saving sub / user\_id in another database

**URL:** <https://community.auth0.com/t/saving-sub-user-id-in-another-database/52513>\
**Category:** Get Help\
**Tags:** user\_id\
**Created:** [October 31, 2020, 8:53am UTC](https://community.auth0.com/t/saving-sub-user-id-in-another-database/52513 "2020-10-31T08:53:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![romanreypedrero](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/romanreypedrero/32/22507_2.png) [@romanreypedrero](https://community.auth0.com/u/romanreypedrero)\
**Post date:** [October 31, 2020, 8:53am UTC](https://community.auth0.com/t/saving-sub-user-id-in-another-database/52513/1 "2020-10-31T08:53:53Z")

</div>

Hi here,

Is it a good practice to store the `user_id` / `sub` in a external databse?

I want to provide a controlled resouce access to my application. That means a user can only modify the resources that he created.  
I thought of saving the **sub** field of an **accesstoken** in the stored document that the user created. So, I can check whether the incoming access\_token sub field matches with the one stored in the document.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 3, 2020, 7:18pm UTC](https://community.auth0.com/t/saving-sub-user-id-in-another-database/52513/3 "2020-11-03T19:18:11Z")

</div>

Hi @romanreypedrero,

Welcome to the Community!

Yes, you can use the sub claim (the user’s Auth0 user\_id), as the unique identifier for the user.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 30, 2020, 9:09pm UTC](https://community.auth0.com/t/saving-sub-user-id-in-another-database/52513/4 "2020-11-30T21:09:41Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
