MySQL数据库设计的服务列表

时间:2022-01-28 12:46:11

Below is a preview of the type of list I am talking about.

下面是我正在谈论的列表类型的预览。

MySQL数据库设计的服务列表

What is going to happen is each user is going to have their own list that they can create. They will be able to modify the headings (Maintenance, Tire Services) and modify each item and add to it and add more rows.

会发生的是每个用户都有他们自己的列表。他们将能够修改标题(维护,轮胎服务)和修改每个项目,并添加到它和添加更多的行。

Here is a database design I had in mind:

下面是我想到的一个数据库设计:

titles: id - name - user_id

标题:id - name - user_id

  • 1 - Maintenance - 1
  • 1 -维护- 1
  • 2 - Tire Services - 1
  • 2 -轮胎服务- 1

services: id - title_id - name - user_id

服务:id - title_id - name - user_id

  • 1 - 1 - Wiper Blades - 1
  • 1 - 1 -雨刷叶片- 1
  • 2 - 1 - Cooling System - 1
  • 2 - 1 -冷却系统- 1
  • 3 - 2 - Tire Rotation - 1
  • 3 - 2 -轮转- 1
  • 4 - 2 - Wheel Balance - 1
  • 4 - 2 -车轮平衡- 1

Is that a decent schema? I tried to keep it to 1 table and just have a "type" field for either "title" or "service" but then realized if it was a service, I didn't know how to specify which title it was supposed to be under.

这是一个合适的模式吗?我试图将它保持在一个表中,并为“title”或“service”设置一个“type”字段,但后来意识到如果它是一个服务,我不知道如何指定它应该在哪个标题下。

Just trying to learn how to do things the right way and was wondering what you guys would do in this situation and if this is a good idea?

我只是想学习如何用正确的方式做事我想知道在这种情况下你们会怎么做如果这是个好主意呢?

Thanks!

谢谢!

1 个解决方案

#1


3  

Based on my assumptions of what you are trying to achieve, you will not need a user_id in services as you can get that from the related title.

基于我对您所要实现的目标的假设,您将不需要在服务中使用user_id,因为您可以从相关的标题中获得。

#1


3  

Based on my assumptions of what you are trying to achieve, you will not need a user_id in services as you can get that from the related title.

基于我对您所要实现的目标的假设,您将不需要在服务中使用user_id,因为您可以从相关的标题中获得。