我正在为服务提供商设计数据库结构。以下是我到目前为止的情况:
+---------+ +----------+ +-----------------+ +-----------------+
| User | | Order | | OrderItems | | Subscription |
+---------+ +----------+ +-----------------+ +-----------------+
| user_id +--+ order_id +--+ order_id +--+ subscription_id |
+---------+ | user_id | | subscription_id | | user_id |
+----------+ +-----------------+ | service_plan_id |
+--------+--------+
|
+------------------+ +-------------------+ +--------+--------+
| ServiceGroup | | ServicePlanAccess | | ServicePlan |
+------------------+ +-------------------+ +-----------------+
| service_group_id +---+ service_plan_id +---+ service_plan_id |
+------------------+ | service_group_id | +-----------------+
+-------------------+
服务组和服务计划之间存在差异 - 服务组定义对服务A或B的直接访问。服务计划可能包括多个服务组,因此授予对多个服务的访问权限(例如,访问A + B)。以下是计划3允许访问组1和组2的示例:
+--------------------+
| ServicePlanAccess |
+--------------------+
| plan_id | group_id |
+--------------------+
| 1 | 1 |
| 2 | 2 |
| 3 | 1 |
| 3 | 2 |
+--------------------+
2。这是一个合理的数据库设计,可以改进吗?