A quick question about database structure

Hey everyone!

I was just wondering if I could get a quick answer about how collections communicate with eachother given this example:

I create 3 collections - Weeks > Days > Hours

If I create two relationships between Weeks & Days and Days & Hours, does Hours also need a relationship with Weeks? Or will Adalo do it’s magic and recognise which week the hour belongs to from the Weeks & Days relationship?

Edit: And further more, does it make sense to just link everything up to everything to widen my flexibility with how/when I can display data? (I’m believing this is true)

I’d be happy to help! But first can you tell me your end goal. How are you going to be collecting/displaying/using the data?

Hey there.

This question was more aligned to the example that I provided, you can forget about the further question in the edit.

I’ve generally relied on the implied relationships between the collections rather than creating additional relationships. So in your example you can derive a relationship between hours and weeks because you have relationships between hours and days and days and weeks.

In fact, adding an additional relationship may make it considerably harder to maintain the links between records when add or update items.

Hi @Briggsy,

First part of the answer - if you create a relationship Weeks - Days, and relationship Days - Hours, then Weeks will not have a direct relationship with Hours.

Second part of the answer - the possibility to access data via intermediate relationship will depend on the type of relationship. For instance, if you have the following structure:

Weeks 1 - Days Many
Days 1 - Hours Many

Then, if you try to access data from some Hours or Days record from Weeks record, you will not be able to do it. Reason: one Week record can have many Days records - which data Adalo needs to display to you?

However, if you take an Hour record, you can get the data from “parent” Day record, and, consequently, from Day’s “parent” Week record - as there is only one record in the relationship, so Adalo can get the data.

As a reminder - I’m talking about direct data access here, not about how would it be possible to access the data in a certain screen - this is a different story (with lists, filtering, counts, visibility, etc.).

Reg. Many-to-Many relationships - as I know you can’t access a certain record’s data directly.

As a final note, I would agree with @Jacob_Lange’s question about the goal. In order to give the proper recommendation, it will be useful to know what is the exact case you’re facing.

The example of Weeks - Days - Hours is too abstract. For instance, if you’re building a calendar and want to display names of weeks, days and hours, then you have 52 Weeks - 7 Days per Week - 24 Hours per day; in this case the easiest way will be to have Many-to-Many relationships (otherwise you will have to create 8736 records in Hours collection0.

If you’re building the booking system, then as an option you might need the 4th collection - timeslots, which will have 1:many relationships to Weeks, Days and Hours, so that each Timeslot will have a combination of three.

Hope this helps.

Best regards, Victor.

Thank you very much for your responses. I’ve now got a much better understanding!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.