MySQL Database Design for a list of services

▼魔方 西西 提交于 2019-12-24 15:42:54

问题


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

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

  • 1 - Maintenance - 1
  • 2 - Tire Services - 1

services: id - title_id - name - user_id

  • 1 - 1 - Wiper Blades - 1
  • 2 - 1 - Cooling System - 1
  • 3 - 2 - Tire Rotation - 1
  • 4 - 2 - Wheel Balance - 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.

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:


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.



来源:https://stackoverflow.com/questions/8566600/mysql-database-design-for-a-list-of-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!