I noticed that when I add a table reference, it adds a column to both tables.
For example, if I have a table of goals, that references goal_types. Not only do I get the goal_types field in the goal table, but I also get a goal field in goal_types.
Is this a real field? if this goals table scaled too a large number of records, it would seem odd to have a single column tracking so many linked goal rows.
Thanks!
Hey @stephengpope! The when a relationship is established between two tables, the relationship itself is displayed on each table as a field of type Table
.
This allows for GraphQL queries to easily access related records, or collections, of records through the field name (really the association name). So for example; you have Goals and GoalTypes tables and a many-to-many relationship between these tables.
The relationship name on Goals table may be “types” and on GoalTypes table “goals”. This way, either query would work.
query {
goalList {
items {
types { count }
}
}
}
query {
goalTypesList {
items {
goals { count }
}
}
}
I think what @stephengpope is asking is if it uses a secondary table for each “reverse association”, in which I think the answer is no. It should just be two tables, joined in different ways I believe.
I’m gonna jump in here and add a thought as well:
I read this as a one to many relationship from goals (many) to goal_types (one).
I expect the table schema will be a table for goals with a column for goal_type, and a table for goal_types with no reference to the goals table.
The GraphQL resolvers just happen to let you traverse the relationships as if goals was a field on goal_types, even though the data model isn’t like that (because yeah it would be horrendously inefficient)