本文介绍了MySQL数据库设计服务列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 下面是我正在谈论的列表类型的预览。 会发生什么是每个用户都有自己的列表,他们可以创建。他们将能够修改标题(维护,轮胎服务)并修改每个项目并添加到其中并添加更多行。 这里是一个数据库设计头脑: 标题: id - name - user_id 1 - 维护 - 1 2 - 轮胎服务 - 1 服务: id - title_id - name - user_id 1 - 1 - 刮水片 - 1 2 - 1 - 冷却系统 - 1 3 - 2 - 轮胎旋转-1 4 - 2 - 车轮平衡-1 这是一个体面的模式吗?我试图保持它的1表,只是有一个类型字段为标题或服务,但后来意识到如果它是一个服务,我不知道如何指定它应该是在哪个标题。 只是试图学习如何以正确的方式做事情,想知道你们在这种情况下会做什么,如果这是一个好主意? 谢谢! 解决方案根据我的假设你想要实现,你不需要 user_id 在服务中,您可以从相关的标题 $ bBelow 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_id1 - Maintenance - 12 - Tire Services - 1services: id - title_id - name - user_id1 - 1 - Wiper Blades - 12 - 1 - Cooling System - 13 - 2 - Tire Rotation - 14 - 2 - Wheel Balance - 1Is 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! 解决方案 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. 这篇关于MySQL数据库设计服务列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 03:34