Re: Is this database structure correct? Please help oh wise ones :)
Posted by: Rick James
Date: October 14, 2009 07:06PM

I have a lot of comments about your schema. Since you want to become a DBA, I will nitpick on the details. (I'm not doing this to be mean; as a DBA, you will need to learn these and many other things.)

car_id int(5) primary key
* Please learn that "(5)" has nothing to do with the range of values for car_id.
* Consider SMALLINT (or other sized int)
* An id is usually UNSIGNED, so state
* PRIMARY KEY should be NOT NULL

year int(4)
* There is a datatype "year"; consider using it instead of INT.
* Again: NOT NULL (presumably)

cost double(5,2)
* That will round to two decimal places on input, then convert to binary, thereby leading to future roundoff problems. Suggest DECIMAL(5,2) instead.

name varchar(20)
* Character set? These days, utf8 is "thinking globally"
* Then, utf8_unicode_ci is 'better'.
* I'll bet you have encountered names longer than 20 characters.
* Perhaps you will need to look up a buyer by his name?

tel int(10)
* This time the misinterpretation of "(10)" will lead to a bug.
* Think globally.

origin varchar(15)
* What is "origin" about? (A COMMENT would have helped.)

Missing fields?
* When (eg, when was repair made)
* Who (eg, who entered the data; who repaired; etc)
* Where (...)

What SELECTs will be done against this schema? Given them, we can discuss whether you need more indexes.

Since you mention FOREIGN KEYs, I assume you will be using InnoDB?

Come back with SHOW CREATE TABLE for each, and I may see more details to critique.

Good luck.

Options: ReplyQuote


Subject
Written By
Posted
Re: Is this database structure correct? Please help oh wise ones :)
October 14, 2009 07:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.