'Hibernate Mappings vs Database Mappings

Hibernate provides annotations (OneToOne, OneToMany, etc) to maintain table relationships. We can achieve same at database level by implement PK and FK.

My question is, In spring boot project what will be the best way to handle these relations, shall I handle at code level or only at database level.



Solution 1:[1]

It has to be done with both at the database level and the code level. Because at the code level give clarity to the java objects and at the database level it gives clarity for the database level.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 venkatasubramanian pattabirama