I am using Laravel 5.5 and MySql. I cannot figure out how to relate Categories, and Sub Categories to Services without adding a subCategoryID
column to the Services
table.
Currently this is my table structure
Service_Categories
id, name
1, Legal Services
2, Personal Drivers
Service_Sub_Categories
id, ServiceCategoryID, name
1, 1, US Legal Services
2, 1, Europe Legal Services
3, 1, Canada Legal Services
Services
id, serviceCategoryID, name
1, 1, US Legal Services Comapny INC
2, 1, Canada Legal Services Company INC
3, 2, JSY Personal Drivers
4, 2, XYZ Personal Drivers
One service must have at least 1 Service Category but it can also have 0 or more Sub-Categories
As you can see, Personal Drivers has no sub-category, but Legal Services has many Sub-Categories. When a user selects "US Legal Services" I only want to pull those up. I could easily add a subCategoryID
column to the Services
table but in the future I may have sub-sub-categories. What is the best way to structure my tables?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire