Table Reference for multiple tables

Options

When you have an integer, you're able to link it to another table as a table reference.

Technically speaking, it's just an integer, and if I want to, I can link it to multiple tables if I need to? Example below, with the following Tables:

  1. Posts
  2. Birthdays
  3. Comments

Both Posts and Birthdays can have comments, so under Table 3, Comments, I can have a "Parent" field, which could link to both Posts and Birthdays.

Within Xano, I just have it as an ordinary integer field, and not link it to any table, but in my queries and function stack, I can still use that integer as an ID to query both the Posts and Birthdays table should I need to.

What do you guys think? Or should I not structure my data in such a way?

Tagged:

Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    You can absolutely do that - but you should keep in mind that this will not profit from joins or foreign key relationships at the database level. You'll need function stack code to know what kind of resource you are linking to. That's not the end of the world, but the price we pay for this flexibility is complexity and a performance hit.