小编rat*_*ing的帖子

Best practise for polymorphic associations in MySQL

I have a MySQL database with 3 tables holding the main classes of data:

 companies (company_id)
 persons (person_id, company_id) 
 loans (loan_id, company_id) 
Run Code Online (Sandbox Code Playgroud)

Both a 'loan' and a 'person' belong to a company. A company can have loans and a company can have people (such as directors, employees etc.)

There are several scenarios where other data can belong to either a company, a person or a loan, such as 'notes'. For example a user can add a 'note' specific to either …

mysql inheritance polymorphic-associations

4
推荐指数
1
解决办法
7754
查看次数