BCAV_WEB Posted October 21, 2010 Share Posted October 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/216472-mysql-structure-help-linking-tables/ Share on other sites More sharing options...
Metalzed Posted October 22, 2010 Share Posted October 22, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/216472-mysql-structure-help-linking-tables/#findComment-1125390 Share on other sites More sharing options...
BCAV_WEB Posted October 25, 2010 Author Share Posted October 25, 2010 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 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. Quote Link to comment https://forums.phpfreaks.com/topic/216472-mysql-structure-help-linking-tables/#findComment-1126105 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.