· 8 years ago · Apr 16, 2018, 02:30 PM
1drop database if exists loja_online;
2create database loja_online;
3use loja_online;
4
5drop table if exists clothing;
6drop table if exists clothing_picture;
7drop table if exists clothing_type;
8drop table if exists clothing_details;
9drop table if exists color;
10drop table if exists cliente;
11drop table if exists packaging;
12
13create table clothing_size(
14 id int (2) primary key auto_increment,
15 size varchar(5) NOT NULL
16);
17
18create table clothing_color(
19 id int (3) primary key auto_increment,
20 color varchar(20) NOT NULL,
21 image varchar(200) NOT NULL
22);
23
24create table clothing_type(
25 id int(2) primary key auto_increment,
26 tipo varchar(30) NOT NULL
27);
28
29create table clothing(
30 id int(4) primary key auto_increment,
31 id_type int(2) NOT NULL,
32 nome varchar(50) NOT NULL,
33 description varchar(500) NOT NULL,
34 id_color int (3) NOT NULL,
35 id_picture int(5),
36 price decimal(4,2) NOT NULL,
37 FOREIGN KEY (id_type) REFERENCES clothing_type(id),
38 FOREIGN KEY (id_color) REFERENCES clothing_color(id)
39);
40
41create table clothing_picture(
42 id int(5) primary key auto_increment,
43 id_clothing int(4) NOT NULL,
44 path varchar(200) NOT NULL,
45 FOREIGN KEY (id_clothing) REFERENCES clothing(id)
46);
47
48create table clothing_details(
49 id int (5) primary key auto_increment,
50 id_clothing int(4) NOT NULL,
51 id_size int(2) NOT NULL,
52 units int(4),
53 FOREIGN KEY (id_clothing) REFERENCES clothing(id),
54 FOREIGN KEY (id_size) REFERENCES clothing_size(id)
55);