database relationships

前端 未结 8 1281
无人共我
无人共我 2021-01-16 09:15

does setting up proper relationships in a database help with anything else other than data integrity?

do they improve or hinder performance?

8条回答
  •  粉色の甜心
    2021-01-16 09:50

    Relationships in the data exist whether you declare them or not. Declaring and enforcing the relationships via FK constraints will prevent certain kinds of errors in the data, at a small cost of checking data when inserts/updates/deletes occur.

    Declaring cascading deletes via relationships helps prevent certain kinds of errors when deleting data.

    Knowing the relationships helps to make flexible and correct use of the data when forming queries.

    Designing the tables well can make the relationships more obvious and more useful. Using relationships in the data is the primary power behind using relational databases in the first place.

提交回复
热议问题