forked from SandrineJa/simplon_marketplace
/
simplon_marketplace.sql
160 lines (127 loc) · 3.72 KB
/
simplon_marketplace.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
-- phpMyAdmin SQL Dump
-- version 4.9.3
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost:8889
-- Généré le : mar. 13 oct. 2020 à 14:24
-- Version du serveur : 5.7.26
-- Version de PHP : 7.4.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
CREATE DATABASE simplon_marketplace;
-- --------------------------------------------------------
--
-- Structure de la table `brands`
--
CREATE TABLE `brands` (
`brand_name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `categories`
--
CREATE TABLE `categories` (
`category_name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `categories_products`
--
CREATE TABLE `categories_products` (
`category_name` varchar(255) NOT NULL,
`code_ean_13` bigint NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `products`
--
CREATE TABLE `products` (
`code_ean_13` bigint NOT NULL,
`product_name` varchar(255) DEFAULT NULL,
`short_description` varchar(255) DEFAULT NULL,
`long_description` varchar(255) DEFAULT NULL,
`brand_name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `products_sellers`
--
CREATE TABLE `products_sellers` (
`id_seller` int(11) NOT NULL,
`code_ean_13` bigint NOT NULL,
`price_ht` float DEFAULT NULL,
`shipping_ht` float DEFAULT NULL,
`stock` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Structure de la table `sellers`
--
CREATE TABLE `sellers` (
`id_seller` int(11) NOT NULL,
`seller_name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `brands`
--
ALTER TABLE `brands`
ADD PRIMARY KEY (`brand_name`);
--
-- Index pour la table `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`category_name`);
--
-- Index pour la table `categories_products`
--
ALTER TABLE `categories_products`
ADD PRIMARY KEY (`category_name`,`code_ean_13`),
ADD KEY `code_ean_13` (`code_ean_13`);
--
-- Index pour la table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`code_ean_13`),
ADD KEY `brand_name` (`brand_name`);
--
-- Index pour la table `products_sellers`
--
ALTER TABLE `products_sellers`
ADD PRIMARY KEY (`id_seller`,`code_ean_13`),
ADD KEY `code_ean_13` (`code_ean_13`);
--
-- Index pour la table `sellers`
--
ALTER TABLE `sellers`
ADD PRIMARY KEY (`id_seller`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `sellers`
--
ALTER TABLE `sellers`
MODIFY `id_seller` int(11) NOT NULL AUTO_INCREMENT;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `categories_products`
--
ALTER TABLE `categories_products`
ADD CONSTRAINT `categories_products_ibfk_1` FOREIGN KEY (`category_name`) REFERENCES `categories` (`category_name`),
ADD CONSTRAINT `categories_products_ibfk_2` FOREIGN KEY (`code_ean_13`) REFERENCES `products` (`code_ean_13`);
--
-- Contraintes pour la table `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`brand_name`) REFERENCES `brands` (`brand_name`);
--
-- Contraintes pour la table `products_sellers`
--
ALTER TABLE `products_sellers`
ADD CONSTRAINT `products_sellers_ibfk_1` FOREIGN KEY (`id_seller`) REFERENCES `sellers` (`id_seller`),
ADD CONSTRAINT `products_sellers_ibfk_2` FOREIGN KEY (`code_ean_13`) REFERENCES `products` (`code_ean_13`);