Closed ThierryMatheus closed 2 years ago
-- Servidor: 127.0.0.1 -- Versão do servidor: 10.4.17-MariaDB - mariadb.org binary distribution -- OS do Servidor: Win64 -- HeidiSQL Versão: 11.1.0.6116
/!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /; /!40101 SET NAMES utf8 /; /!50503 SET NAMES utf8mb4 /; /!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /; /!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' /; /!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 /;
-- Copiando estrutura para tabela veganologo.comments
CREATE TABLE IF NOT EXISTS comments
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id
bigint(20) unsigned NOT NULL,
recipe_id
bigint(20) unsigned NOT NULL,
comment_comment
text NOT NULL,
PRIMARY KEY (id
),
KEY FK_33
(user_id
),
KEY FK_42
(recipe_id
),
CONSTRAINT FK_31
FOREIGN KEY (user_id
) REFERENCES user
(id
),
CONSTRAINT FK_40
FOREIGN KEY (recipe_id
) REFERENCES recipe
(id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Copiando dados para a tabela veganologo.comments: ~0 rows (aproximadamente)
DELETE FROM comments
;
/!40000 ALTER TABLE comments
DISABLE KEYS /;
/!40000 ALTER TABLE comments
ENABLE KEYS /;
-- Copiando estrutura para tabela veganologo.evaluation
CREATE TABLE IF NOT EXISTS evaluation
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
evaluation_note
int(11) NOT NULL,
user_id
bigint(20) unsigned NOT NULL,
recipe_id
bigint(20) unsigned NOT NULL,
PRIMARY KEY (id
),
KEY FK_59
(recipe_id
),
KEY FK_62
(user_id
),
CONSTRAINT FK_57
FOREIGN KEY (recipe_id
) REFERENCES user
(id
),
CONSTRAINT FK_60
FOREIGN KEY (user_id
) REFERENCES recipe
(id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Copiando dados para a tabela veganologo.evaluation: ~0 rows (aproximadamente)
DELETE FROM evaluation
;
/!40000 ALTER TABLE evaluation
DISABLE KEYS /;
/!40000 ALTER TABLE evaluation
ENABLE KEYS /;
-- Copiando estrutura para tabela veganologo.favorites
CREATE TABLE IF NOT EXISTS favorites
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id
bigint(20) unsigned NOT NULL,
recupe_id
bigint(20) unsigned NOT NULL,
PRIMARY KEY (id
),
KEY FK_49
(user_id
),
KEY FK_52
(recupe_id
),
CONSTRAINT FK_47
FOREIGN KEY (user_id
) REFERENCES user
(id
),
CONSTRAINT FK_50
FOREIGN KEY (recupe_id
) REFERENCES recipe
(id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Copiando dados para a tabela veganologo.favorites: ~0 rows (aproximadamente)
DELETE FROM favorites
;
/!40000 ALTER TABLE favorites
DISABLE KEYS /;
/!40000 ALTER TABLE favorites
ENABLE KEYS /;
-- Copiando estrutura para tabela veganologo.recipe
CREATE TABLE IF NOT EXISTS recipe
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id
bigint(20) unsigned NOT NULL,
recipe_name
varchar(45) NOT NULL,
recipe_img
text NOT NULL,
recipe_ingredients
text NOT NULL,
recipe_time
varchar(45) NOT NULL,
recipe_utensils
text NOT NULL,
PRIMARY KEY (id
),
KEY FK_18
(user_id
),
CONSTRAINT FK_16
FOREIGN KEY (user_id
) REFERENCES user
(id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Copiando dados para a tabela veganologo.recipe: ~0 rows (aproximadamente)
DELETE FROM recipe
;
/!40000 ALTER TABLE recipe
DISABLE KEYS /;
/!40000 ALTER TABLE recipe
ENABLE KEYS /;
-- Copiando estrutura para tabela veganologo.user
CREATE TABLE IF NOT EXISTS user
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_name
varchar(45) NOT NULL,
user_email
varchar(45) NOT NULL,
user_password
varchar(45) NOT NULL,
time_stamp
datetime NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Copiando dados para a tabela veganologo.user: ~0 rows (aproximadamente)
DELETE FROM user
;
/!40000 ALTER TABLE user
DISABLE KEYS /;
/!40000 ALTER TABLE user
ENABLE KEYS /;
/!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') /; /!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) /; /!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /; /!40111 SET SQL_NOTES=@OLD_SQL_NOTES /;
To entendendo nada do deu codigo, explica?
É só que eu deixei comentado algumas coisas, mas basicamente eu crio a tabela se ela ainda não existir e se existir eu limpo os dados que já haviam nela, sacou?
Eu como desenvolvedor do sistema preciso criar um modelo de Banco de dados para salvar os dados do sistema