Re: Data Modelling Challenge

2010-08-05 Thread cricket
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

Re: Data Modelling Challenge

2010-08-05 Thread Graham Weldon
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

Data Modelling Challenge

2010-08-05 Thread keymaster
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

Problem about data modelling in CAKEPHP

2009-05-25 Thread marco.rizze...@gmail.com
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 |

Re: Data Modelling

2007-01-19 Thread RichardAtHome
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

Re: Data Modelling

2007-01-19 Thread Jon Bennett
"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

Re: Data Modelling

2007-01-19 Thread RichardAtHome
"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

Re: Data Modelling

2007-01-19 Thread Jon Bennett
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

Re: Data Modelling

2007-01-19 Thread RichardAtHome
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

Data Modelling

2007-01-19 Thread Jon Bennett
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