Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

database regarding cars - for mysql

Tags:

database

mysql

i have a dilema regarding my database design for my car system (my dad own a dealership and i want to build him a new system where the user can schedule test drives, apptointmen etc...)

i am undecide between these 2 models:

table car
 id int, model_id int, make_id int, price float, year year, millage int, etc...

or

table car
 id int, model enum, make enum, price float, year year, millage intetc...

customer table with (id int, name varchar, phone int, street varchar, city etc...

salemen table with (id int, name varchar, etc...

schedule table (id int, appt_Date datetime, car_id, customer_id, salemen_id)

now my question is this:

should I use enum fields or should i have a table for each enum fields? i dont want to redesign the system once it is use by everyone and start all over again.

thanks

like image 382
fred Avatar asked Dec 20 '11 01:12

fred


1 Answers

I would stay away from ENUMs for one main reason. If you want to add new items, you have to ALTER the table. Which can be painful if you have tons of data. Also, depending the collation and the character set you use, you have be careful with case sensitivity.

Read this article for more info: 8 Reasons Why MySQL's ENUM Data Type Is Evil.

Now using a reference data/table using a foreign key is preferable because you can have a data integrity rule. You can build a simple tool to manage these data (make or model) without altering or changing any database schema.

like image 146
Book Of Zeus Avatar answered Sep 17 '22 18:09

Book Of Zeus