hi guys.. i am designing a brand new car database system.. I create entity-relationship model but it seems garbage.i uploaded the model.
When i want select something in database i write lots of absurd codes like
brand_name,model_name,fuel_type,car_type,engine_lt ,price FROM
Is this right way or are there any easy ways to do that database..?
for example, take fuel_type -- why would you split that off into a separate table? why wouldn't you just have fuel_type as an attribute of the car?
well (he said, answering his own question), the only possibility i can think of is that you want a controlled vocabulary -- you want people entering data for a car to be restrictred to only the values of fuel type that have already been predefined in the fuel table, using a foreign key relationship
if that's true, then my next question question is, why would you use an id for that, instead of the actual fuel_type value?
He means that you are trying to ensure the values are always spelled the same, which can be almost gauranteed through the use of a foreign key that E-89 is what gets into the car table rather than sometimes you have E-89, E89, Ethanol89 and so on. The reason I say almost gauranteed using foreign keys as you have defined already, the other spellings could be added to your fuel table and then make it into your car table. Most places I have been have had a single code table of some sort and you use those codes as a drop down for selection, to try to ensure you get the correct value, rather than having a 100 or more tables that contain a couple of values and their codes, such as fuel type car type etc...