我只是想要一些关于 mysql 数据库的建议。我正在为需要维修和修理的租用汽车创建一个新数据库。我创建了 4 个表。 Car_id 链接到包含汽车信息的主键表。我正在考虑将 Repair_id 和 service_id 放入汽车数据表中。但这意味着一张表中有 3 个主键。这样可以吗?
车库表 -
- 车库 id(主键)
- 车库名称
- 机械师 fname
- 机械师 sname
- 地址
- 电话
机械师数据 -
- 机械师 id(主键)
- 车库 id(外键)
- Mec 名称
维修数据 -
- 维修 id(主键)
- 汽车 id(外键)
- 工作描述
- Mec id(外键)
服务数据 -
- 服务 id(主要)
- 汽车 id(外键)
- 工作描述
- Mec id(外键)
我稍微修改了表格。你怎么认为。它会起作用吗?
车库数据是
Garage_id
车库名称
文件名
姓
地址
电话号码
类型数据为
Type_code ------------ 维修时为 1 号,维修时为 2 号
Type_description 维修/服务
机械数据是
机械人 ID
车库 ID
输入_code
Repair_id
汽车 ID - 我已经为此创建了一个表
工作描述
Mec ID
服务 ID
车牌号
作品说明
Mec id
谢谢你帮助我。如果您能看看是否可以的话,这将会很有用。
I just want some advice about mysql database. I'm creating a new database for hired cars that need servicing and repairs. I have created 4 tables. Car_id is linked to a primary key table with car information. I was thinking of putting the repair_id and service_id with in the car data table. But that means it will have 3 primary keys in one table. WIll this be okay?
Garage table-
- Garage id (Primary key)
- Garage name
- Mechanics fname
- Mechanics sname
- address
- Phone
Mechanic data-
- Mechanics id (Primary key)
- Garage id (Foreign key)
- Mec name
Repair data-
- Repair id (Primary key)
- Car id (Foreign key)
- Work description
- Mec id (Foreign key)
Service data-
- Service id (primary)
- Car id (Foreign key)
- Works description
- Mec id (Foreign key)
I have slightly altered the table. What do you think. Will it work?
Garage data is
Garage_id
Garage name
fname
surname
address
Phone number
type data is
Type_code ------------ will be number 1 for repair and number 2 for service
Type_description repair/service
mecanics data is
Mec id
Garage id
Type _code
Repair_id
Car id - i have created a table already for this
Work description
Mec id
Service id
Car id
Works description
Mec id
Thank you for helping me. It will be useful if you can see if its okay.
发布评论
评论(2)
repair
应该有一个car_id
列。将repair_id
放入car
意味着您只能对一辆车进行一次维修,我认为这不是您想要的限制。service_id
也是如此。repair
should have acar_id
column. Puttingrepair_id
incar
implies that you can only ever have one repair for a car, which I assume isn't a limitation you'd want.Same thing for
service_id
.我建议使用一个带有参考工作类型表的工作表;这样您就可以随意添加工作类型,6 个月服务、12 个月服务、MOT、维修、翻新等。机械师应该进入他们自己的表,也许员工会更好,然后你可以有一个包含经理、高级机械师等的员工类型参考表。
当然,这个答案假设您有一个车辆表。
garage_sites(garage_site_id、garage_name等)
mech_staff(mStaff_id、garage_site_id_fk、名称等)
vehicle_job(vJob_id、vehicle_id_fk、vJob_type_code_fk、mStaff_id_fk)
< strong>vehicle_job_type(vJob_type_id, vJob_type_code, vJob_type_description)
您可以在以下位置找到大量指针和基础数据库模型:
http://www.databaseanswers.org/data_models/index.htm
I would advise a single table for jobs with a reference job types table; this way you can add job types at will, 6mnth service, 12month service, M.O.T, Repair, Refurbishment etcetera. Mechanics should go into their own table, perhaps staff would be better, then you could have a staff type reference table with manager, senior mech, etcetera.
Of course this answer assumes you have a vehicle table.
garage_sites(garage_site_id, garage_name, etc)
mech_staff(mStaff_id, garage_site_id_fk, name, etc)
vehicle_job(vJob_id, vehicle_id_fk, vJob_type_code_fk, mStaff_id_fk)
vehicle_job_type(vJob_type_id, vJob_type_code, vJob_type_description)
You can find a lot of pointers and base database models at:
http://www.databaseanswers.org/data_models/index.htm