-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandax.sql
140 lines (124 loc) · 2.68 KB
/
pandax.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
DROP DATABASE pandax;
CREATE DATABASE pandax;
--
-- Table structure for table publisher
--
CREATE TABLE publisher
(id int(32) NOT NULL AUTO_INCREMENT
,denomination varchar(128) NOT NULL
,PRIMARY KEY (id)
);
--
-- Table structure for table media_type
--
CREATE TABLE media_type
(id int(32) NOT NULL AUTO_INCREMENT
,label varchar(128) NOT NULL
,PRIMARY KEY (id)
);
--
-- Table structure for table user
--
CREATE TABLE user
(id int(32) NOT NULL AUTO_INCREMENT
,pseudo varchar(128) NOT NULL
,pwd varchar(128) NOT NULL
,first_name varchar(128) NOT NULL
,last_name varchar(128) NOT NULL
,is_admin boolean NOT NULL DEFAULT 0
,PRIMARY KEY (id)
,CONSTRAINT user_login UNIQUE (pseudo)
);
--
-- Table structure for table media
--
CREATE TABLE media
(id int(32) NOT NULL AUTO_INCREMENT
,title varchar(128) NOT NULL
,published date NOT NULL
,descript text NOT NULL
,image_url varchar(128) NOT NULL
,city varchar(128) NOT NULL
,user int(32) NOT NULL
,publisher int(32) NOT NULL
,media_type int(32) NOT NULL
,PRIMARY KEY (id)
,FOREIGN KEY (user) REFERENCES user(id)
,FOREIGN KEY (publisher) REFERENCES publisher(id)
,FOREIGN KEY (media_type) REFERENCES media_type(id)
);
--
-- Table structure for table comment
--
CREATE TABLE comment
(user int(32) NOT NULL
,media int(32) NOT NULL
,id int(32) NOT NULL AUTO_INCREMENT
,date_made date NOT NULL
,content text NOT NULL
,PRIMARY KEY (id)
,FOREIGN KEY (user) REFERENCES user(id)
,FOREIGN KEY (media) REFERENCES media(id)
);
--
-- Table structure for table possesion
--
CREATE TABLE possession
(user int(32) NOT NULL
,media int(32) NOT NULL
,date_acquired date NOT NULL
,PRIMARY KEY (user, media)
,FOREIGN KEY (user) REFERENCES user(id)
,FOREIGN KEY (media) REFERENCES media(id)
);
--
-- inserts for media type
--
INSERT INTO media_type (label) VALUES
('Animation'),
('Animation série'),
('Documentaire'),
('Émission TV'),
('Film'),
('Série TV'),
('Bande dessinée'),
('Comic'),
('Livre'),
('Manga'),
('Presse'),
('Album'),
('Album live'),
('Compilation'),
('Jeu vidéo'),
('Peinture'),
('Fond d’écran'),
('Gravure');
--
-- inserts for publisher
--
INSERT INTO publisher (denomination) VALUES
('Evil Corp.'),
('Metal Records'),
('Studio Ghibli'),
('VALVe'),
('id Software'),
('Motörhead-sued Motörhead label'),
('BLU Corp.'),
('RED Corp.'),
('Weyland-Yutani'),
('CyberDyne Systems'),
('Black Mesa'),
('Aperture Science');
--
-- inserts for user
--
INSERT INTO user (pseudo, pwd, first_name, last_name, is_admin) VALUES
('louis','lemmy-ftw','Louis','Prud’homme',true),
('melanie','chocolat','Mélanie','Marques',false),
('sebastien','ghost-ftw','Sébastien','Bernard',true),
('anil','rince-colon','Anil','Devadas',true),
('panda','panda','Xi','Jinping',true);
--
-- What remains
--
COMMIT;