-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
22 lines (20 loc) · 795 Bytes
/
init.sql
File metadata and controls
22 lines (20 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CREATE DATABASE IF NOT EXISTS cidades_db;
USE cidades_db;
CREATE TABLE IF NOT EXISTS `Cidades` (
`CidadeId` int NOT NULL AUTO_INCREMENT,
`Nome` varchar(100) NOT NULL,
`Sigla` char(2) NOT NULL,
`IBGEMunicipio` int NOT NULL,
`Latitude` decimal(11,8) DEFAULT NULL,
`Longitude` decimal(11,8) DEFAULT NULL,
PRIMARY KEY (`CidadeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `Aluno` (
`AlunoId` int NOT NULL AUTO_INCREMENT,
`Nome` varchar(100) NOT NULL,
`Idade` int NOT NULL,
`CidadeId` int NOT NULL,
`Foto` longblob,
PRIMARY KEY (`AlunoId`),
CONSTRAINT `FK_Aluno_Cidades` FOREIGN KEY (`CidadeId`) REFERENCES `Cidades` (`CidadeId`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;