I am trying to figure out how 1 table can have connections to multiple tables and on which field the relationships are created.
I have a Student table with a Course_ID field and a Sports_ID field, a Courses table with primary key Course_ID and Description fields. I also have a Sports table with primary key Sports_ID and Description fields.
Coming from an SQL world, I can create a link between the Course_ID field and the Sports_ID field in the Students table to both the related fields in the Courses and Sports tables.
Basically Adalo’s many-one relationships are using foreign keys under the hood - exactly like in SQL. Many-many relationships are (I assume) junction tables under the hood, but in Adalo that is simplified so you can connect 2 collections instantly, without creating a 3rd one.
@SynopsisLabs so what exact problem do you encounter? Did you read the help article about Adalo Collections relationships?
This is exactly many-to-one relationships between Students and Courses (one student can have only one course, but a course can have many Students), and same with Sports.
How does Adalo know what field in the Students table to link to the ID field in the Courses and Sports tables. I could potentially have many more fields in the students table linked to other tables.
I removed the Courses ids from the Students table, yet a course is still showing up in the preview
What does the second ID field in the tables come from and what does it content represent?
I decided to try to get it to work using local databases first as the list component has more options. So I am trying to understand how the local tables link.
As said before, I am from the SQL world where all relationships are explicit, so I am trying to rewire my grey matter!
@SynopsisLabs Adalo uses PostgreSQL in the backend. Think of it like: “ID” field is the Identity and Primary Key. When you create a relationship to another table, you do not need to add an explicit foreign key field and set it up - Adalo does it for you. So fk_courses will always point to courses.id.
But anyway you should not worry about it - Adalo does the job for you. You do NOT need to create a numeric ID field to store ID of a related collection (unless you want to do complex manual filtering which is quite rare case).
Also I would avoid naming any field as “ID” to prevent possible confusions. Internally, manually-created fields have different naming anyway, but in the frontend sometimes things may happen.
@SynopsisLabs apparently the relationship removal is not being processed instantly on the backend. But anyway if you remove the magic text showing this value, you won’t be able to recreate it again.