(MYSQL的n00b)在這種情況下使用int而不是bigint有什麼好處?
我有3個表:
ID = INT(10),photo_id = BIGINT(20)
PHOTO記錄侷限於3000000
PHOTO:
+-------+-----------------+
| id | photo_num |
+-------+-----------------+
| 1 | 123456789123 |
| 2 | 987654321987 |
| 3 | 5432167894321 |
+-------+-----------------+
COLOR:
+-------+-----------------+---------+
| id | photo_num | color |
+-------+-----------------+---------+
| 1 | 123456789123 | red |
| 2 | 987654321987 | blue |
| 3 | 5432167894321 | green |
+-------+-----------------+---------+
SIZE:
+-------+-----------------+---------+
| id | photo_num | size |
+-------+-----------------+---------+
| 1 | 123456789123 | large |
| 2 | 987654321987 | small |
| 3 | 5432167894321 | medium |
+-------+-----------------+---------+
COLOR和SIZE表格都會有數百萬條記錄。
Q1:是更好地改變顏色和大小photo_num
到int(10)
並將其指向照片的ID?
現在我使用這些:(PHOTO是在畫面任何地方)
SELECT * from COLOR WHERE photo_num='xxx';
SELECT * from SIZE WHERE photo_num='xxx';
Q2:如何將SELECT查詢一下,如果有照片的證件的顏色是使用,大小?
分裂的原因是因爲SIZE和COLOR分別有10列。爲了簡單起見,我在這裏只使用了2列。 – Yeti 2010-06-10 11:35:01