· 6 years ago · Jan 22, 2020, 04:57 PM
1drop database if exists Yugioh;
2create database Yugioh;
3use Yugioh;
4
5create table Cards (
6CardID int(8) not null,
7Expansion_ varchar(10) not null,
8Category varchar(7) not null, -- magia/trappola/mostro
9Name_ varchar(30) not null,
10Attribut varchar(20), -- solo per i mostri terra/fuoco/acqua/luce/oscurita/vento/divinita
11level_ int(2), -- va da 0 a 12
12type_ varchar(20), -- tipo del mostro/rapida/continua/normale/counter
13sub_type1 varchar(25), -- solo per mostri
14sub_type2 varchar(25), -- solo per mostri
15sub_type3 varchar(25), -- solo per mostri
16sub_type4 varchar(25), -- solo per mostri
17atk int, -- solo per mostri
18def int, -- solo per mostri
19linkrate int(9), -- solo per link
20primary key (CardID,Expansion_) );
21
22create table Cards_possession (
23ID int auto_increment ,
24CardID int(8) not null,
25Expansion_ varchar(10) not null,
26Quantity int,
27
28primary key (ID,CardID,Expansion_)
29);
30
31alter table Cards
32Add constraint FK_Cards_possesion
33foreign key(CardID)
34references Cards_possession(CardID);