Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 DROP TABLE IF EXISTS domains; | |
2 DROP TABLE IF EXISTS corrections; | |
3 | |
4 CREATE TABLE domains( | |
5 id INT NOT NULL AUTO_INCREMENT, | |
6 domain VARCHAR(50) NOT NULL, | |
7 domain_correct FLOAT(10,10), | |
8 correction_correct FLOAT(10,10), | |
Wladimir Palant
2012/10/09 11:51:14
Aren't these two fields just derivatives of the da
| |
9 PRIMARY KEY(id) | |
10 ); | |
11 | |
12 CREATE TABLE corrections( | |
13 id INT NOT NULL AUTO_INCREMENT, | |
14 domain INT NOT NULL, | |
15 status INT NOT NULL, | |
16 curr_month INT NOT NULL, | |
17 prev_month INT NOT NULL, | |
18 curr_year INT NOT NULL, | |
19 prev_year INT NOT NULL, | |
20 PRIMARY KEY(id), | |
21 FOREIGN KEY(domain) REFERENCES domains(id) | |
22 ); | |
23 | |
24 CREATE UNIQUE INDEX idx_domain ON domains(domain); | |
25 CREATE UNIQUE INDEX idx_domain_status ON corrections(domain, status); | |
Wladimir Palant
2012/10/09 11:51:14
Use UNIQUE constraint instead of these two indexes
Thomas Greiner
2012/10/09 13:47:02
I prefer having indexes because SELECTs on this ta
Wladimir Palant
2012/10/09 14:17:08
A UNIQUE constraint will always create an index im
| |
OLD | NEW |