· 6 years ago · Jan 06, 2020, 10:38 PM
1CREATE TABLE IF NOT EXISTS pictures
2(
3 pictureID INT NOT NULL,
4 stockitemID INT NOT NULL,
5 picture VARCHAR(255) NULL,
6 FOREIGN KEY (stockitemID) REFERENCES stockitems(StockItemID)
7)
8ENGINE=InnoDB
9DEFAULT CHARSET=latin1;
10
11ALTER TABLE pictures
12 ADD PRIMARY KEY (pictureID);
13
14ALTER TABLE pictures
15 MODIFY pictureID INT NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
16COMMIT;
17
18insert into pictures (stockitemID, picture) VALUES(1,'resources/images/1/usb1.jpg');
19insert into pictures (stockitemID, picture) VALUES(1,'resources/images/1/usb2.jpg');
20insert into pictures (stockitemID, picture) VALUES(1,'resources/images/1/usb3.jpg');
21insert into pictures (stockitemID, picture) VALUES(2,'resources/images/2/usb1.jpg');
22insert into pictures (stockitemID, picture) VALUES(2,'resources/images/2/usb2.jpg');
23insert into pictures (stockitemID, picture) VALUES(2,'resources/images/2/usb3.jpg');
24insert into pictures (stockitemID, picture) VALUES(3,'resources/images/3/periscope1.jpg');
25insert into pictures (stockitemID, picture) VALUES(3,'resources/images/3/periscope2.jpg');
26insert into pictures (stockitemID, picture) VALUES(3,'resources/images/3/periscope3.jpg');
27insert into pictures (stockitemID, picture) VALUES(25,'resources/images/25/mug1.jpg');
28insert into pictures (stockitemID, picture) VALUES(25,'resources/images/25/mug2.jpg');
29insert into pictures (stockitemID, picture) VALUES(25,'resources/images/25/mug3.jpg');
30insert into pictures (stockitemID, picture) VALUES(26,'resources/images/26/mug1.jpg');
31insert into pictures (stockitemID, picture) VALUES(26,'resources/images/26/mug2.jpg');
32insert into pictures (stockitemID, picture) VALUES(26,'resources/images/26/mug3.jpg');
33insert into pictures (stockitemID, picture) VALUES(27,'resources/images/27/mug1.jpg');
34insert into pictures (stockitemID, picture) VALUES(27,'resources/images/27/mug2.jpg');
35insert into pictures (stockitemID, picture) VALUES(27,'resources/images/27/mug3.jpg');