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