# Best user identifier to use to store in local database

**URL:** <https://community.auth0.com/t/best-user-identifier-to-use-to-store-in-local-database/11783>\
**Category:** Get Help\
**Tags:** user\_id, custom-database\
**Created:** [May 23, 2018, 3:57pm UTC](https://community.auth0.com/t/best-user-identifier-to-use-to-store-in-local-database/11783 "2018-05-23T15:57:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrissslee93](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@chrissslee93](https://community.auth0.com/u/chrissslee93)\
**Post date:** [May 23, 2018, 3:57pm UTC](https://community.auth0.com/t/best-user-identifier-to-use-to-store-in-local-database/11783/1 "2018-05-23T15:57:51Z")

</div>

This question was already asked here [here](http://community.auth0.com/t/storing-the-user-id-in-a-local-database/7471), but the answer wasn’t entirely satisfactory.

[This documentation](https://auth0.com/docs/user-profile/normalized/auth0#uniquely-identify-users) claims that `user_id` is the best field to use as the unique identifier, but the problem with that field is that it has an undefined length due to the variable length of any identity provider/connection name. This implies that the only appropriate SQL data-type for user\_id would be TEXT which cannot be indexed. Does the raw pre-concatenated `id` field have a set/maximum length? As in, if I limit the identity providers to only “Auth0” (5 characters), is the character length of `user_id` known (so I can use an index-able data-type like VARCHAR[length] instead of TEXT)?

---

<div class="post-metadata">

**Author:** ![sgmeyer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sgmeyer/32/3387_2.png) [@sgmeyer](https://community.auth0.com/u/sgmeyer)\
**Post date:** [May 23, 2018, 4:08pm UTC](https://community.auth0.com/t/best-user-identifier-to-use-to-store-in-local-database/11783/2 "2018-05-23T16:08:27Z")

</div>

@chrissslee93 you can always track your own key. It isn’t common for customers to store their own unique identifier on the user’s app\_metadata field. This would allow you to control the data type. Besides using `user_id` or this approach I don’t see another option.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 25, 2019, 1:19pm UTC](https://community.auth0.com/t/best-user-identifier-to-use-to-store-in-local-database/11783/3 "2019-07-25T13:19:22Z")

</div>


