Page 1 of 1

normalization help

Posted: Sun Oct 24, 2010 6:55 am
by rob1
Hi, im new to php and mysql and im working on my first mini project to help me progress my knowledge and skills.

im building a simple carwash/valeting website that allows users to provide contact details and details of their car

ive created 3 tables as below,

contact details
make
model

how should i link the make and model table to the main contact details table, would i also need a 4th table to link the make and models together?

the intention is to have some kind of fee scale/band linked to the model of car ie big car will cost you more. to then complicate matters further the existing condition of the car will also +/- a percentage ie bad condition will cost you more

please could someone provide some assistance to get me started, i really want to do things correctly, rather than just stick everything in one/two tables

thanks

Rob

Re: normalization help

Posted: Sun Oct 24, 2010 7:25 am
by s.dot
The make table should have an id, and the model table would use it as make_id to link the model to the make (foreign key).
In the contact table, there should be a make_id and model_id field to link it to the make and models tables.

That is how I would do it, I think.

EDIT| Let me explain the tables a little bit more, for example

[text]contact
id | name | phone | etc | make_id | model_id

make
id | make

model
id | make_id | model[/text]

Re: normalization help

Posted: Sun Oct 24, 2010 8:22 am
by rob1
thanks for this, i think its just what i need to get started

Re: normalization help

Posted: Sun Oct 24, 2010 5:48 pm
by VladSun
s.dot wrote:[text]contact
id | name | phone | etc | make_id | model_id

make
id | make

model
id | make_id | model[/text]

The contact table doesn't need both make_id and model_id - it's already in the model table. so it should be:

[text]contact
id | name | phone | etc | model_id

make
id | make

model
id | make_id | model[/text]