Sounds like you need to simplify.
Everything there is a region, and a region would have a type.
A region can belong to another region through a child-parent relationship.

Country is a Region
State is a Region
Region is a Region

So:

Region
- id
- parent_id
- type
- name

This will allow you to model all the types you need.


On Thu, Aug 5, 2010 at 8:19 PM, keymaster <[email protected]> wrote:
> The context is a standard ecommerce platform.
>
> A Country hasMany States.
> Some Countries have no States.
> A Region can be made up of either:
> 1. entire Countries, or
> 2. States within a Country.
>
> The following Data Model does not work:
>
> Region HABTM Country hasMany State
>
> ... because there are Countries where some States belong to one
> region, and some State belong to a different region.
>
> If we add:
>
> Region hasMany State
>
> ... so that States can belong to Regions independant of the country
> they are a part of, we end up with a potential data inconsistency.
> This can arise if the user assigns a State to a Region, but forgets to
> assign the Country (the State belongs to) also to that region.
>
> Ideas please...
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to