Constraint validation


I have this following use case.

_id, name

_id, name, base1_id

so basically… base2 is a linked relation, parent -> child

on base3

_id, base1_id, base2_id

so base2_id is a relation that brings all the linked (children) of base 1… I need to be able to pick one or several but not all (like it is linked), but I need to make sure that they are children of the base1_id, so I need some kind of validation there.

Any idea how to fulfill this use case?