On Thu, Aug 5, 2010 at 6:19 AM, keymaster 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.
I suggest you use only the 2nd definition. I
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 mo
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 Countrie
Hi
I have a problem about modelling data of my application and I don't
know how resolve it.
I present my situation:
My E-R is
__ _
| | N/\M ||
| Document | \>| DocumentField |
Its duplicated data because you are already storing which branches
belong to a company via the users table (users belong to a company AND
a branch).
If you use a nullable foreign key for the branch id you can also
represent people who are in the company but not associated with any
particular bra
"and Branch belongsTo Company (without that, there's no correlation
Company and Branch) "
and again you'd be duplicating information ;-)
how so? A Branch does belong to a Company, and a Company does have
many Branches - I don't get how that's duplication.
I would have thought having a user b
"and Branch belongsTo Company (without that, there's no correlation
Company and Branch) "
and again you'd be duplicating information ;-)
You could get a list of branches for each company via the users table
Get branches for company:
SELECT DISTINCT branches.id, branches.name
FROM branches
INN
You would break the rules of database normalisation if you linked the
users to the company. You would be duplicating data.
thought so!
Note: Breaking the rules of database normalisation will not condemn
your soul to an eternity in the pit - sometimes the real world gets in
the way of a perfe
You would break the rules of database normalisation if you linked the
users to the company. You would be duplicating data.
Note: Breaking the rules of database normalisation will not condemn
your soul to an eternity in the pit - sometimes the real world gets in
the way of a perfect ideal.
An al
Hi,
I've got a quick data modelling question.
I have 3 tables, Companies, Branches and Users. Would you add a FK to
Company in User like so:
Company hasMany Branch,User
Branch hasMany User
Branch belongsTo Company
User belongsTo Branch,Company
Or would you leave the FKs to Company out
10 matches
Mail list logo