简化数据库关系设计
I have this little Laravel project where members can pay to attend to a class, pay insurance, event, or pay to pass a special type of exams.
So I have 5 tables members
, classes
, insurance
, events
and exams
, and I need to add the payments
table so I can track members payments for each one of those tables.
So for the moment the payments
table is going to be like this :
id date amount member_id class_id insurance_id event_id exam_id
1 2019-01-01 150 2 1 NULL NULL NULL
2 2019-01-01 250 11 NULL 14 NULL NULL
3 2019-01-01 220 15 NULL NULL 6 NULL
4 2019-01-01 350 32 NULL NULL NULL 8
Is there a better way to this without having :
class_id, insurance_id, event_id, exam_id
fields in the payments table, because this is going to make the relationship more complexe I guess, and to also maybe simply DB queries using Laravel as a PHP Framework.
duanliujie8639
2019/03/21 09:59- laravel
- php
- mysql
- 点赞
- 收藏
- 回答
满意答案
2个回复
