-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scriptssql.txt
58 lines (52 loc) · 1.65 KB
/
Scriptssql.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- Creating the Products table
CREATE TABLE Products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
inventory INT NOT NULL CHECK (inventory >= 0)
);
-- Inserting 20 sample fashion product entries
INSERT INTO Products (name, price, inventory) VALUES
('T-shirt Blanc', 19.99, 100),
('Jean Slim Noir', 49.99, 75),
('Chaussures de Sport', 89.99, 50),
('Veste en Cuir', 199.99, 25),
("Robe d'Été", 29.99, 60),
('Cravate en Soie', 24.99, 40),
('Sac à Main', 59.99, 30),
('Chapeau Panama', 34.99, 20),
('Écharpe en Laine', 29.99, 45),
('Ceinture en Cuir', 39.99, 70),
('Montre Classique', 149.99, 15),
('Bottes en Cuir', 99.99, 40),
('Lunettes de Soleil', 79.99, 50),
('Chemise à Carreaux', 44.99, 55),
('Pull-over Gris', 64.99, 35),
('Short en Jean', 39.99, 60),
("Sandales d'Été", 49.99, 40),
('Bijoux Fantaisie', 14.99, 85),
('Pantalon Chino', 54.99, 50),
('Blouse Florale', 39.99, 40);
-- Create Orders table
CREATE TABLE Orders (
orderId INT PRIMARY KEY AUTO_INCREMENT,
totalPrice DECIMAL(10,2)
);
-- Inserting 3 orders
INSERT INTO Orders (totalPrice) VALUES (150.00), (200.50), (75.20);
-- Create OrderDetails table
CREATE TABLE OrderDetails (
id INT PRIMARY KEY AUTO_INCREMENT,
orderId INT,
productId INT,
soldQuantity INT,
FOREIGN KEY (orderId) REFERENCES orders(orderId),
FOREIGN KEY (productId) REFERENCES products(id)
);
-- Inserting 5 order details
INSERT INTO OrderDetails (orderId, productId, soldQuantity) VALUES
(1, 1, 3),
(1, 2, 2),
(2, 3, 1),
(3, 1, 4),
(3, 3, 2);