As a relational product Brimbox allows three type of relationships:
This document being prepared for v2.3
- Parent Child relationships are similar to One to Many relationships in standard database design. See http://www.brimbox.com/parent-child-relationships/ for more information.
- Related relationships which are also One to Many relationships but do not require absolute relational integrity if desired. They are setup differently than the Parent Child relationships by default in Brimbox. See http://www.brimbox.com/related-layouts/.
- Join Relationships are Many to Many relationships in Brimbox. They are called Join relationships because of the way the relationship is stored. See http://www.brimbox.com/join-relationships/ for a detailed description.
Consider the following Brimbox database design:
With a Join Relationship defined right below:
In this scenario B2 has a Parent A1 so there is a Parent Child relationship between Animals and Expenses. Animals (A1) have a Join relationship to layout Owners (C3) and Owners (C3) have a Join relationship to Amimals (A1). So Animals can have multiple Owners and Owners can have multiple Animals.
Considering Animals only have one Breed and we want to store additional information about Breeds we can add a related layout:
We need to go to the Animals column definitions and add the related table (in columns c41 to c46):
In this case, assuming an Animal can only have one Breed, we have defined a Parent Child (which is 1 to Many) relationship between Animals and Expenses, and a Related relationship Breeds to Animals (which is 1 to Many). So Animals retains a primary status in the database layout, however Breeds does have a 1 to Many relationship with Animals.
We could have Breeds be the Parent of Animals and Animals the Parent of Expenses but it makes more sense to have Animals be primary, or accessible without drilling down from Breeds.