How does MySQL implement nesting of another table within a table?
为情所困
为情所困 2017-05-18 10:50:13
0
1
617

1. I am a database novice... If I want to realize the A column in database table 1, how to implement the BCD column in nested table 2? Use foreign keys?
2. If I use foreign keys, I always get errors when creating and saving them:

incorrect foreign key definition for 'xxx':key reference and table reference dont match

What's going on with this problem? How to solve it?

为情所困
为情所困

reply all(1)
过去多啦不再A梦

The use of foreign keys is not recommended. Foreign keys will cause coupling between tables and may cause deadlocks. And these errors are not easy to find during the programming process.

Suppose you now want to combine table A and table B. Then you add a new column in table A to save the id value in table B.

  • Saving process: Save table B first, then return the id value and save it into table A.

  • Retrieval process: First retrieve table A, and then retrieve the corresponding table B data based on the id of table A.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!