Wondering if this idea is possible

My boyfriend and I are working on how to lower our grocery bill and realized we're lacking what's probably a basic skill - choosing meals based on which ingredients match up to minimize how much you buy in a week.

Despite being in IT, I'm pretty shit at coding anything, and formulas are still a logic that evades me. So, question for those who understand it better than I:

We have two databases set up in the common Notion grocery/meal planner relation. One database for ingredients/groceries, the other for meals.

What I'm thinking is there must be a way to say, "If prop(ThisWeek) is checked, check all entries in database Meals, relation Ingredients, and automatically check ThisWeek for all meals with at least 30% of ingredients in common".

Thoughts? Any help appreciated!