Home > database >  MySQL when establish foreign key?
MySQL when establish foreign key?

Time:09-18

MySQL when establish foreign key?

CodePudding user response:

Don't set up outside the healthy

CodePudding user response:

Foreign key fields to constraints of scope, but very impact performance and extend, so don't establish a foreign key, it is ok to be consistent in logic, referred to as "logic of foreign keys, what you said is called physical foreign keys

CodePudding user response:

Foreign key is the main table and child table need associated soho key, simple, for example, the main table is a class a brief information (for example, contains the student age, class, home address, phone number), the child table is student achievement (language for every division success), then requires the corresponding foreign key associated students grades, otherwise you won't know what kind of result, the student is

CodePudding user response:

From the point of data integrity and consistency, with a foreign key is definitely a good choice, besides, the database can help you do the why don't you let it do? But you are from the perspective of development or operational, with foreign key to cause a decline in maintain the extension performance, lights,

CodePudding user response:

The actual development don't use a foreign key, the business logic to control the main foreign key relationships,
  • Related