Relationships, Permissions, etc

:wave: - It’s been some time since I worked with glideapps – can someone please help to entangle my thoughts as I ran myself into a spin:
allow me to layout an example:
user table: with user roles as “Teacher” “Student” and “Admin”
and tables:

  • “Class” where “Teacher” is the “Lead” of its “flock of students”;
  • “Rooms” where Teacher can book a Room;
  • “Supplies” that are organized in “Categories”

each table has RowID plus corresponding properties (i.e. ClassID, Name, TeacherID, Image, etc.), with relations between tables using RowID or other ID to establish the relationship.

Now: I understand that in order to create relations I need a common column to be present in both tables:
let say I want to connect Class Table with Teachers table: what if I have the relationship established in spreadsheet (or sql db) where there are only two columns: TeacherID and ClassID – this is a common process (I think) in database relationship, but it confuses me when I have to translate that in glideapps: It seems to me that if I want to create a screen from a table, that table must have all elements (=columns) that will represent what I want to visually show on the screen:
it means, that if I have my relationships table (= 2 columns) I am unable to refer to the properties, i.e. show me class name and teacher’s name and image… – it seems as if I need to build each table with all the elements represented as columns in order to show it in a screen…

So: am i correct to assume that I have to build table with all relationships and lookups for all the fields I want to present on screen? What if the relationships are more complex?

I hope I’m making this clear to follow – thanks for clarifying!

Hola!

A short answer is yes but I’d recommend you the documentation to understand it better and save your time: Relations | Glide Docs

It depends a bit on what you’re trying to show, let’s say if you want to display the teacher’s info in the Class’ details view, then:

  • Have a relation from the Class table to the User table using the TeacherID.
  • Next, add a collection pointing to that relation. You’ll be able to display the teacher’s info, and be able to let users click on that item as well to view the teacher’s details screen for example.

But say you don’t want that and need to have the teacher’s name as a separate field to display somewhere else, then you need a lookup on top of that relation.