Here’s what I’m thinking (excuse the Django format):
class VehicleMake(Model):
name = CharField(max_length=50)
class VehicleModel(Model):
make = ForeignKey(VehicleMake)
name = CharField(max_length=50)
class VehicleYear(Model):
model = ForeignKey(VehicleModel) # or ManyToManyField
year = PositiveIntegerField()
This is going to be used in those contingent drop-down select boxes, which would visually be laid out like [- Year -][- Make -][- Model -]. So, to query the data I need I would first have to select all distinct years from the years table, sorted descending. Then I’d find all the vehicle makes that have produced a model in that year. And then all the models by that make in that year. Is this a good way to do it, or should I re-arrange the foreign keys somehow? Or use a many-to-many table for the years/models so that no year is repeated?
I would go for:
This should allow you to group up Buick, Chevrolet, Cadilac etc. under “General Moters”
Also I think your UI logic is slightly flawed,
This shouds like a job for a “walk right” menu, ie, you need a pulldown of all your manufacturers, when a particular manufacturer is selected you can present a sub-menu of models, when a model is selected you can then preset a sub menu of years.
Alternativly you should edit the contents of the “model” selection whenever a new manufacturer is selected, then whenever a model is selected the year selection should be updated.
As described your UI would allow me to enter a “Studebaker” “Model T” “2010”