mysql 市场架构帮助

mysql schema help for marketplace

我正在为我的下一个项目(市场)规划数据库模式,请检查以下...

tbl_users - id, email, password, created_at
countries - id, name
states - id, name, country_id
cities - id, name, state_id
areas - id, name, city_id
tbl_profiles - id, user_id, area_id, full_name, about, pic, email, phone, created_at

这之后我有点困惑,现在我需要创建 4-5 个 profile_categories,例如机械师、油漆工、干洗工、仆人等,但这些将被分成不同的 service_types示例画家可以分为 - 干画家、油画画家、玻璃画家等。所以我决定提出以下结构...

tbl_mechanics - id, profile_id
tbl_mechanic_services - id, service_name

由于它的多对多关系,我正在使用 pivot table 来连接两者

tbl_mechanic_service_pivot - id, mechanic_id, service_id

现在我应该为其余配置文件类别使用相同的数据库结构吗...

tbl_painters - id, profile_id
tbl_painter_services - id, service_name
tbl_painter_service_pivotv- id, painter_id, service_id

我的上述方法是否正确,或者您能提出更好的解决方案吗?

谢谢

你为什么不往这边走(如果我猜对了你的目标):

tbl_service_type: id, title
tbl_service_category: id, service_type_id, title

因此,如果您的每个配置文件只有 1 个类别,您可以将新字段 service_category_id 添加到您的 tbl_profiles

如果每个配置文件都可以分配给多个类别,您可以创建数据透视表 table:

tbl_profile_categories: id, profile_id, service_category_id