-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanco.sql
32 lines (27 loc) · 882 Bytes
/
banco.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
CREATE DATABASE IF NOT EXISTS sistema_de_emprestimo_de_ferramenta;
USE sistema_de_emprestimo_de_ferramenta;
drop table if exists ferramentas;
drop table if exists amigos;
drop table if exists emprestimos;
CREATE TABLE ferramentas (
id INT AUTO_INCREMENT PRIMARY KEY,
nome VARCHAR(100) NOT NULL,
marca VARCHAR(255) NOT NULL,
custo DOUBLE NOT NULL
);
CREATE TABLE amigos (
id INT AUTO_INCREMENT PRIMARY KEY,
nome VARCHAR(100) NOT NULL,
apelido VARCHAR(100),
telefone VARCHAR(20) NOT NULL
);
CREATE TABLE emprestimos (
id INT AUTO_INCREMENT PRIMARY KEY,
id_ferramenta INT NOT NULL,
id_amigo INT NOT NULL,
data_inicial DATE NOT NULL,
data_prazo DATE NOT NULL,
data_devolucao DATE,
FOREIGN KEY (id_ferramenta) REFERENCES ferramentas(id),
FOREIGN KEY (id_amigo) REFERENCES amigos(id)
);