Recently I was designing a library table for an enterprise application project, and I encountered some data association problems. I was undecided whether it would be better to maintain within the code or make external associations. I am seeking the opinions of experts.
Let me tell you my personal opinion.
Normally, it is recommended to use database foreign keys. This has relatively complete constraints. Moreover, most applications (80%) of most companies have not yet reached the level of database segmentation. So why not just rely on the integrity of the database? ?
Not using foreign keys is usually too large, so the number should be more than a million. Need to be segmented. Only manually use the program maintenance. . .
The demand is stable - use foreign keys
The demand changes frequently - don’t use it