Relationships
Database Relationships are used to define related data between one or more tables.
Last updated
Database Relationships are used to define related data between one or more tables.
Last updated
Quick Definition
Database relationships show how different tables of data connect to each other - like how a customer's ID links their personal information to their complete order history. These relationships can be one-to-one (one person, one social security number), one-to-many (one customer, many orders), or many-to-many (many students can take many classes).
In Xano, there are three primary ways tables can be related:
This is like a person and their unique passport. Each data entry in one table relates to exactly one entry in another table.
Think of a parent and their children. A single entry in one table can relate to multiple entries in another. For example, one teacher can teach many students.
Similar to students enrolling in various courses, any entry in one table can relate to multiple entries in another.
Data Consistency: Ensures all references are valid.
Reduced Redundancy: Minimizes repeated data.
Efficient Data Retrieval: Makes it easier to access related data.
Understanding these basic concepts can simplify how you view databases and highlight why tools like Xano are powerful for managing data.
When you add a table reference field to a database table, that field simply stores the IDs of the record(s) being referenced; the data is not actually duplicated. To access the actual data is typically done via an add-on as part of a function stack.
Auto-Complete allows you to configure how the referenced records look inside of other tables.
For this example, we have two tables: user
and userRole