· 8 years ago · Jun 11, 2018, 05:40 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_color(
14 id int (3) primary key auto_increment,
15 color varchar(20) NOT NULL,
16 image varchar(200) NOT NULL
17);
18
19 create table clothing_type(
20 id int(2) primary key auto_increment,
21 id_clothing int(4) NOT NULL,
22 tipo varchar(30) NOT NULL
23);
24
25create table clothing_picture(
26 id int(5) primary key auto_increment,
27 id_clothing int(4) NOT NULL,
28 path varchar(200) NOT NULL
29);
30
31create table clothing_size(
32 id int (2) primary key auto_increment,
33 size varchar(5) NOT NULL
34);
35
36create table clothing_details(
37 id int (5) primary key auto_increment,
38 id_clothing int(4) NOT NULL,
39 id_size int(2) NOT NULL,
40 units int(4),
41 FOREIGN KEY (id_size) REFERENCES clothing_size(id)
42);
43
44create table clothing(
45 id int(4) primary key auto_increment,
46 id_type int(2) NOT NULL,
47 nome varchar(50) NOT NULL,
48 description varchar(500) NOT NULL,
49 id_color int (3) NOT NULL,
50 id_picture int(5),
51 price decimal(4,2) NOT NULL,
52 addeddate date default null,
53
54 FOREIGN KEY (id_type) REFERENCES clothing_type(id),
55 FOREIGN KEY (id_picture) REFERENCES clothing_picture(id),
56 FOREIGN KEY (id_color) REFERENCES clothing_color(id)
57);