-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.sql
155 lines (126 loc) · 3.64 KB
/
cart.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
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 27, 2021 at 11:01 PM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 7.3.25
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: `cart`
--
-- --------------------------------------------------------
--
-- Table structure for table `cart`
--
CREATE TABLE `cart` (
`id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`rate_id` int(11) NOT NULL,
`vat` double(13,4) NOT NULL,
`shipping` double(13,2) NOT NULL,
`discount` varchar(60) DEFAULT NULL,
`price` double(13,4) NOT NULL,
`total` double(13,4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(11) NOT NULL,
`Item_type` varchar(100) NOT NULL,
`Item_price` double(13,2) NOT NULL,
`shipping_rates_id` int(11) DEFAULT NULL,
`weight` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `Item_type`, `Item_price`, `shipping_rates_id`, `weight`) VALUES
(1, 'T-shirt', 30.99, 3, '0.2'),
(2, 'Blouse', 10.99, 4, '0.3'),
(3, 'Pants', 64.99, 4, '0.9'),
(4, 'Sweatpants', 84.99, 5, '1.1'),
(5, 'Jacket', 199.99, 3, '2.2'),
(6, 'Shoes', 79.99, 5, '1.3');
-- --------------------------------------------------------
--
-- Table structure for table `shipping_rates`
--
CREATE TABLE `shipping_rates` (
`id` int(11) NOT NULL,
`country` varchar(50) NOT NULL,
`rate` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `shipping_rates`
--
INSERT INTO `shipping_rates` (`id`, `country`, `rate`) VALUES
(3, 'US', 2),
(4, 'UK', 3),
(5, 'CN', 2);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cart`
--
ALTER TABLE `cart`
ADD PRIMARY KEY (`id`),
ADD KEY `product_id_foriegn` (`product_id`),
ADD KEY `rate_id_foreign` (`rate_id`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`),
ADD KEY `shipping_rates_id` (`shipping_rates_id`);
--
-- Indexes for table `shipping_rates`
--
ALTER TABLE `shipping_rates`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `cart`
--
ALTER TABLE `cart`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `shipping_rates`
--
ALTER TABLE `shipping_rates`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `cart`
--
ALTER TABLE `cart`
ADD CONSTRAINT `cart_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `cart_ibfk_2` FOREIGN KEY (`rate_id`) REFERENCES `shipping_rates` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;
--
-- Constraints for table `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`shipping_rates_id`) REFERENCES `shipping_rates` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;
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 */;