normalization help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rob1
Forum Newbie
Posts: 12
Joined: Mon Jul 28, 2008 10:05 am

normalization help

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: normalization help

Post 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]
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
rob1
Forum Newbie
Posts: 12
Joined: Mon Jul 28, 2008 10:05 am

Re: normalization help

Post by rob1 »

thanks for this, i think its just what i need to get started
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: normalization help

Post 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]
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply