Table id reference - when is it a good idea? - Got users but should i have a teams table?

Options

Hi,

I have a users table for auth, inside I have a table ref to a "managers table"

My plan was to then have a user_id ref to the user table in the managers table as a list to create teams. In my head i feel it makes it more streamlined to get data for employee tables in the front end however, i also feel that it then makes two places that you have to remeber to edit, delete etc… when required.

I have read that its not wise to duplicate data however, with the potential of have a huge user table will having to search for team members based on the manager become difficult over time and potentially slow?

TIA, this community is super helpful!!!

Best Answer

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Answer ✓
    Options

    Hi @HAS1 - you are right, I would not recommend duplicating your relationship because it could compromise data integrity.

    Growing database tables does raise the issue of performant queries. However, Xano leverages postgreSQL database. And you are able to introduce indexes in order to create performant lookups as your database table grows in size. (https://docs.xano.com/database/database-performance/indexes). So your user table ballooning over time should be fine by eventually introducing an index for manager_id (if that's what is being used to look up).

Answers