Home  >  Q&A  >  body text

java - When dealing with data relationships, what are the advantages and disadvantages of using database table foreign keys versus in-code maintenance?

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.

曾经蜡笔没有小新曾经蜡笔没有小新2712 days ago513

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-17 10:10:48

    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. . .

    reply
    0
  • 怪我咯

    怪我咯2017-05-17 10:10:48

    The demand is stable - use foreign keys
    The demand changes frequently - don’t use it

    reply
    0
  • Cancelreply