-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
56 lines (47 loc) · 1.59 KB
/
Copy pathdatabase.sql
File metadata and controls
56 lines (47 loc) · 1.59 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- Criação do banco --
create database if0_36803676_mpsflix;
use if0_36803676_mpsflix;
-- Estrutura de tabelas --
create table tb_usuarios (
email varchar(512) not null primary key,
nome varchar(256) not null,
senha varchar(256) not null
);
create table tb_series (
id_serie int unsigned not null auto_increment primary key,
nome varchar(256) not null,
sinopse varchar(1024) default null
);
create table tb_filmes (
id_filme int unsigned not null auto_increment primary key,
nome varchar(256) not null,
link varchar(256) not null unique,
duracao time not null,
sinopse varchar(1024) default null
);
create table tb_categorias (
id_categoria tinyint unsigned not null auto_increment primary key,
nome varchar(256) not null unique
);
create table tb_categoria_filme (
id int unsigned not null auto_increment primary key,
id_filme int unsigned not null,
id_categoria tinyint unsigned not null,
foreign key (id_filme) references tb_filmes(id_filme),
foreign key (id_categoria) references tb_categorias(id_categoria)
);
create table tb_categoria_serie (
id int unsigned not null auto_increment primary key,
id_serie int unsigned not null,
id_categoria tinyint unsigned not null,
foreign key (id_serie) references tb_series(id_serie),
foreign key (id_categoria) references tb_categorias(id_categoria)
);
create table tb_episodios (
id_episodio int unsigned not null auto_increment primary key,
id_serie int unsigned not null,
numero smallint unsigned not null,
temporada tinyint unsigned not null,
link varchar(256) not null unique,
foreign key (id_serie) references tb_series(id_serie)
);