Skip to content
Back

How to model user data and relationships?

  • 0
  • Databases
  • Auth
  • Web
  • Cloud
Oli
26 Nov, 2025, 12:47

I wonder how to model something like this:

A user can create any amount of events. Each event belongs to one user.

What I have done so far: Created a new tables called 'users' and 'events'. When a user signs up, a new entry in 'users' is created with its id from the built-in auth table. This column is called 'userId'. However, when trying to set relationship to the 'events' table, the relationship is created via the 'user' table rowId. I cannot specify a key unfortunately.

How did you solve this?

Later, I want to do something in an admin dashboard: Get all events from user xyz

TL;DR
To model user data and relationships: - Create tables for 'users' and 'events'. - Use 'userId' as a column in the 'users' table. - Establish a relationship between 'users' and 'events' using the 'userId' column. - For admin dashboard feature: Query and filter events by the specific user's 'userId'.
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