An association relationship must have a reference table, for example:
There is an employee file management system project that includes the following data sheets: Basic information sheets, employee profiles, departmental tables, project group tables, bank card forms (used to record employee card information).
There is a certain correlation between these data tables, and we analyze the association between the other tables as a reference to the Employee Basic information table:
Each employee must have corresponding employee file information, so belong to Has_one association;
Each employee must belong to a department, so it belongs to Belongs_to Association;
Each employee can have multiple bank cards, but each card may belong to only one employee and therefore belong to the Has_many association;
Each employee can be in multiple project groups at the same time, each project group has multiple employees at the same time and therefore belongs to Many_to_many Association;
After analyzing the relationship between the data tables, we can make association definitions and associated operations.
Http://doc.thinkphp.cn/manual/relation_model.html
Main Table
This table uses the ID of the master's member.
The card table also has member ID
Grammatical composition
Relation Correlation Model