Skip to content
Back

how can i make a relationship between a column in a table and $id in auth.users?

  • 0
  • 2
  • Databases
  • Auth
  • Web
dei8bit
13 Feb, 2026, 11:50

i want to relate the $id from users auth table in appwrite with other column in my table user_profile. because is the same user...

how can i have exactly the same id for both tables?

TL;DR
Create a relationship between a column in a table and $id in auth.users by using auth events to copy data into the table when a new user is created. Utilize transaction blocks for atomic operations to ensure the database and auth are in sync. This method may seem counterintuitive but ensures reliable results.
14 Feb, 2026, 08:13

We cant do this actually One of the easiest ways would be via auth events

Whenever a new user is created, shoot a function that copies the data into the table

Or one more way , since we support transactions now and we know transactions are atomic

So I would follow this but can be counter intuitive as well but db and auth would be totally in sync

  1. transaction block
  2. db operation with a custom id for the user table
  3. Use the same id in the auth creation
  4. If auth fails db will not commit your result since inside a transaction block

A bit counter intuitive as auth should be the source of truth and not database but we are doing db operation first. But it will work reliably

1
17 Feb, 2026, 15:40

nice!!!, well at least there's a way to achieve that.

because the problem with auth.users is that assume a solid shape for users. and in the other hand, if you create your own user table, you lose built-in features of auth.users table :p

1
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more