Jump to content

MYSQL Structure Help / Linking tables


BCAV_WEB

Recommended Posts

Hello,

 

I'm currently working on a website that has various different makes of cars, what I would like is to have all the information to come from a back-end database (PHPmyAdmin). This is a list of the following info that would have to go on:

 

1. Car Make, Model, RRP, Our Price, Savings

2. Colours - Orange, blue (along with the image and alt tag)

3. Car Extras - Prices, image etc...

 

My issue is I can't seem to figure / get my head around the structure of the database, I know that I would require a many to many relationship table because one car can have many different colours. However, the colour names, variation change depending on the car specification.

 

Any ideas? And how would I go about having it structured and linked in PHPMyAdmin?

 

Any help would be greatly appreciated, this system would save time and recuding coding on the site dramatically.

 

Thank you

Link to comment
Share on other sites

Maby I am all wrong here but you can do like this.

 

It depends of how big the database will be.

How many cars and so on.

 

TBCars

CarID

Name

ModelID

Hk

....... with all the values every car have

 

TBStats

StatID

StatName

 

TBCarStats

CarID

StatID (INT)

StatValue (Varchar)

 

 

 

In TBCar you have.

CarID=1 Name="A bran new Volvo with everything you need"

CarID=1 Name="A very cheap Ford "

 

 

In TBStats you have.

StatID=1 StatName="color"

StatID=2 StatName="gears"

StatID=3 StatName="AC"

StatID=4 StatName="Image"

 

 

In TBCarStats you have.

StatID=1 CarID=1 Value="Brown"

StatID=1 CarID=1 Value="Green"

StatID=1 CarID=1 Value="Yellow"

StatID=2 CarID=1 Value="5"

StatID=3 CarID=1 Value="Yes"

StatID=3 CarID=1 Value="No"

StatID=4 CarID=1 Value="An image link"

 

StatID=1 CarID=2 Value="Blue"

StatID=2 CarID=2 Value="6"

 

 

 

This will meen that

 

 

 

Car

Name : "A bran new Volvo with everything you need"

Color : Brown or Green or Yellow

Gears : 5

Image : A link

AC : Yes Or No

 

Car 2

"A very cheap Ford "

Color : Blue

Gears : 6

 

 

This way you can add any fact to the cars you like. Exampel you can add 5 colors to one car while just one to another. Or five image to one and so on.

 

 

This is not a good way to do with the whole Database but for some of the Value it is a way.

 

Hope it helps and that i didn't missunderstood your question

Link to comment
Share on other sites

Yes that sounds about rite, but in TBCarStats you have linked the tables together how do you actually do this in PHPmyAdmin, as I've never actually had to do it  :P

 

If you go to www.bcav.org.uk and then select any car you'll see what I want to do, currently it is all manual coding, which is massive. The idea is to reduce this and to have a system where a non technical person can add new cars / edit, hence the back-end database. Doing this would also allow me to work on other systems.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.