database structure for drop down options in form

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
dazzy
Forum Newbie
Posts: 5
Joined: Wed Jul 10, 2013 6:26 am

database structure for drop down options in form

Post by dazzy »

Hi

I want to build a form with drop down lists of car makes and models

The first option will be make of car and the second will be the model of the car.

I will pull the information in from a database to fill in the second option dependent on the make of car.

Does anyone know the best structure of table to create this?

Would it be best to use 2 different tables? One for makes of cars and one for all models of cars? and have them connect dependent on the id of the make of car in the makes table?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: database structure for drop down options in form

Post by Celauran »

That's how I would structure it. car_models.manufacturer_id as a foreign key referencing car_manufacturers.id or somesuch.
dazzy
Forum Newbie
Posts: 5
Joined: Wed Jul 10, 2013 6:26 am

Re: database structure for drop down options in form

Post by dazzy »

Yeah I think I will go that way

Thanks for the help
Post Reply