Questions about foreign keys to tables
clean
clean 2020-04-15 00:05:35
0
1
1029

The teacher would like to ask, why not create foreign key links directly in MySQL? It is the relationship between the foreign key that directly links the two tables

clean
clean

reply all(1)
DY。

Generally, it is not recommended to use foreign key constraints in databases. Since it is called a constraint, it will definitely have defects:

Performance: When inserting data into a sub-table, the main table must be judged.

Concurrency: If you modify the main table, the sub-table (when there is a lot of related data) may cry.

Scalability: Not conducive to expansion. For example, if you have a website that grows from small to large, when the number of visits, data When the volume increases, you may split the database into separate tables...it is very troublesome to have foreign keys.

So: the data in your two tables can be related, just write the comments; instead of You must set foreign keys in the table structure.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template