-
Notifications
You must be signed in to change notification settings - Fork 1
/
ordercraft.sql
190 lines (153 loc) · 4.59 KB
/
ordercraft.sql
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 24, 2023 at 04:18 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `ordercraft`
--
-- --------------------------------------------------------
--
-- Table structure for table `clients`
--
CREATE TABLE `clients` (
`idClient` int(11) NOT NULL,
`nameClient` varchar(255) NOT NULL,
`emailClient` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `clients`
--
INSERT INTO `clients` (`idClient`, `nameClient`, `emailClient`) VALUES
(14, 'yassine', '[email protected]'),
(15, 'fati', '[email protected]'),
(18, 'mohammed', '[email protected]'),
(19, 'ahmad', '[email protected]');
-- --------------------------------------------------------
--
-- Table structure for table `orderitems`
--
CREATE TABLE `orderitems` (
`idOrder` int(11) NOT NULL,
`idProduct` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`total` double(8,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `orderitems`
--
INSERT INTO `orderitems` (`idOrder`, `idProduct`, `quantity`, `total`) VALUES
(20, 38, 10, 202.00),
(20, 40, 30, 1500.00),
(24, 38, 1, 20.20),
(25, 40, 22, 1100.00),
(25, 41, 1, 2500.00),
(26, 38, 1, 20.20);
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`idOrder` int(11) NOT NULL,
`idClient` int(11) NOT NULL,
`dateOrder` date NOT NULL,
`totalOrder` double(8,2) NOT NULL,
`statusOrder` enum('INPROGRESS','CANCELED','DELIVERED') NOT NULL DEFAULT 'INPROGRESS'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`idOrder`, `idClient`, `dateOrder`, `totalOrder`, `statusOrder`) VALUES
(20, 15, '2023-12-24', 1702.00, 'DELIVERED'),
(24, 14, '2023-12-24', 20.20, 'CANCELED'),
(25, 18, '2023-12-24', 3600.00, 'CANCELED'),
(26, 15, '2023-12-24', 20.20, 'DELIVERED');
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`idProduct` int(11) NOT NULL,
`nameProduct` varchar(255) NOT NULL,
`priceProduct` decimal(10,2) NOT NULL,
`stock` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`idProduct`, `nameProduct`, `priceProduct`, `stock`) VALUES
(38, 'mouse', 20.20, 196),
(40, 'keyboard', 50.00, 244),
(41, 'laptop lenovo', 2500.00, 18),
(43, 'laptop hp', 2400.00, 9);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `clients`
--
ALTER TABLE `clients`
ADD PRIMARY KEY (`idClient`);
--
-- Indexes for table `orderitems`
--
ALTER TABLE `orderitems`
ADD PRIMARY KEY (`idOrder`,`idProduct`),
ADD KEY `orderitems_idproduct_foreign` (`idProduct`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`idOrder`),
ADD KEY `orders_idclient_foreign` (`idClient`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`idProduct`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `clients`
--
ALTER TABLE `clients`
MODIFY `idClient` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `idOrder` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `idProduct` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=44;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `orderitems`
--
ALTER TABLE `orderitems`
ADD CONSTRAINT `orderitems_idorder_foreign` FOREIGN KEY (`idOrder`) REFERENCES `orders` (`idOrder`),
ADD CONSTRAINT `orderitems_idproduct_foreign` FOREIGN KEY (`idProduct`) REFERENCES `products` (`idProduct`);
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `orders_idclient_foreign` FOREIGN KEY (`idClient`) REFERENCES `clients` (`idClient`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;