Database relations

Can someone describe this feature in more detail?
Can you do a has_many relationship between two tables?
Can you create a join table and a has_many through relationship?
And is there an approximate ETA?

4 Likes

Available now :slight_smile:
You can do 1-to-many relationships by defining a relationship between the collections
And you can create most many-to-many relationships by filtering one dataset based on the value of another

Fantastic! Is there a video on defining a relationship between the collections? I’m going to experiment with this now!

OK, I just created a two collections:
1.) Teachers
2.) Students
A Teacher has many students. I’m super excited and have no idea what to do next. I don’t see any link to “define a relationship between the collections” so I’m frustrated and confused. :frowning:

Do you add the reference field to Teachers or do you add the reference field column to Students? I added records for Teachers and records for Students. I add a reference field and reference the other table and it just says “no results” in the dropdown. Once again I’m frustrated and confused. Do you have a video on this?

What is the primary key and the foreign key? I am so confused.

Hey Adam,
There isn’t yet a video, but check out the last three articles here
Generally speaking:

1:many relationships can be created by adding a field of type “reference” from the child collection to the parent collection.

many:many relationships can be done by using two datasets on the page, and filtering the child dataset by the parent’s value.

Hope that helps, and don’t forget to check out those articles.

hi guys, im trying to add a function to update a database row by users inserts, but i have no idea how to do, someone can help me?

Ohhhhh!!! You use the Reference field type to select an item from the primary field of the referenced collection. For more information, see How to Create a Reference Field

Hey, Adam,
You usually need more collections, like a Classes collection that references the teacher, and an Enrollment collection with an entry that references a student and a class.

And you can create most many-to-many relationships by filtering one dataset based on the value of another
Sweet! Just asked about this in another thread, so this is great news.

How does referential integrity work for a cascading delete type of situation with referenced collections? If we delete the “one” in a one-many relationship, will it delete the “many” or do we have to put some delete logic via hooks to manually scrub each collection?