So my scenario demands to store details of businesses which offer varied services. One
business can offer n
different services. Since each service is different, details pertaining to a service are in individual tables.
table : business
------------------
business_id,
(other business specific fields)
table: service_types
----------------------
service_type_id,
service_name,
(other service specific fields)
table: business_services
--------------------------
service_type_id_fk,
business_id_fk,
identifier (id to point the record in respective service table)
(other business service specific fields)
table: service_a (similarly many other services - service_b, service_c etc)
------------------
service_id,
service_type_id_fk,
(other service specific fields)
Now I need to find out
- How many services a business provides
- Details of each of the service.
For 1, I can simply look up business_services
table.
But for 2, with the design I have, I have to store the tables names somewhere; either in server side scripting or in a dedicated table. I can may be store it in service_types
table where I store the service name and its table name for further details.
Is it good practice to store table names in a table? Or what could be the best way to address the problem?
NOTE: None of these services are similar and they demand a table for each one. So grouping services into one table is not an option because I want it to be normalized and distribute load as well.
business_services
table for abusiness_id_fk
of1
and aservice_type_id_fk
of1
there will be only one record, no matter what.