Context: Although by default Calpendo contains a complex database structure out of the box, you may have a situation in your own facility which requires adding in an additional database object that will have a relationship with pre-existing database objects. For example, in Calpendo we have the concept of locations, whereby a resource may be placed inside a location such as a lab. But perhaps you want to apply an additional level of organisation to locations by having a Building database object which would contain locations.
Suitable for: Admins. You will also need an understanding of the mechanics of a one-to-many database relationship.
Objective: Create an additional Biskit for storing Buildings and link it through a one to many relationship with locations (where one building has many locations in it)
Steps:
- Setup the new biskit for storing buildings
- Go to the Bakery
- Click Create
- Set the Type of the new biskit to be 'Building'
- Click Add New under properties
- In the new property set the Name to 'Name' and the Type to 'String'
- Add in any additional properties for information specific to the building
- Set the biskits Name Property field to be 'Name' from the list in the dropdown
- Add in a property to link this to the biskit on the many side of the relationship
- Name this property 'locations'
- Make it of Type 'Set'
- Set the Biskit Def to be Location
- Leave the Biskit Property Type as One to Many
- Set Reference Deletion Option to 'Set null'
- Click Save - this will produce an error - press Save Despite Errors (this is because we haven't set up the other side of the link yet)
- Edit the biskit on the many side to link
- Select the Location biskit
- Edit and add a new property called building
- Make it of Type 'Biskit'
- Set the Biskit Def to be Building
- Change the Biskit Property Type to be 'Many to One'
- Change the Inverse Property to be 'locations'
- Save this will produce an error - press Save Despite Errors (this is because we haven't set up all of the link yet)
- Go back to the Building biskit
- Edit and go to the locations property
- Change the Inverse Property to be 'building'
- Save (There should be no errors this time)
- Click DB Schema in the main toolbar for the Bakery (Click Apply Changes when requested)
- Reload DB Configuration and refresh the browser.