I wish you listed things out clearer.
like: Tables:
- clinics
- locations
- zipcodes
and
- clinic1 has 10 zipcodes assigned to it,
- clinic1 has 3 locations
- 1 locations (location1 singular??) are associated with 3 zipcodes
- attached to the clinic (1 or X ?) zip codes 3 out of 10 assigned zip codes. (i'm not sure what this means. clinic X are associated with 3 (out of 10) zipcodes?) <-- you need clarify this!
Also, if you have any schemas you should post them.
Anywho, from what I can understand.
So you should have 3 models here: Clinic Location ZipCode
A Location hasMany(ZipCode) <-- this means A location likely contains one or more zipcodes
A ZipCode belongsTo(locations) <-- this means, a zipcode is associated with ONE location.
A clinic hasMany(Locations) <-- this means, a clinic can service multiple locations A Clinic hasMany(Zipcodes) <-- this means a clinic can service multiple zipcodes
A Zipcode belongsTo (Clinic) <-- this means only one ZipCode can be associated with a clinic. (attached to)
So if this is correct, then it looks like this, yeah?
CLINIC 1 Location 1 Zipcode 1 Zipcode 2 Location 2 Zipcode3 Location 3 'No ZipCode'
which means: A Clinic services one or many locations. A Location can comprise of many zipcodes
Finally, note that just because say a Location hasMany zipcodes, doesn't mean it must have at least one. there could be none.
Does this sound right?
Let me know.