mysql两个表递归,与mysql中的递归一对多关系需要至少4个表?

I have the following relationships (Business rules):

User_Company : Many-to-many (multiple companies per user, multiple users per company)

Ownership : One-to-One (For each entry in relationship table, it specifies whether user is an owner or employee. If owner then a percentage must be there)

Company_ownership : One-to-many for company (Recursive relationship), as another company can also be an owner in a company, percentage must be given.

So ownership or a company can be made up of a number of companies and users.

So I have developed the following:

a48758558208c13cc012d1f4525b15fa.png

So does there have to be at least 4 tables for this sort of relationship or can it be simplified.

I feel it is quite complicated and would not be intuitive for another developer? How could it be optimized and elegantly arranged?

解决方案

I think ownership and employment are different concepts, that would be more advised to have them separated.

Think about John who is one of the owners of A company and in the mean time he is the CTO of A.

Company and People can have a base to reduce redundancy of entities.

10b9bf10326ecec75276bbf173cfea5f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值