· 5 years ago · Mar 08, 2020, 04:54 AM
1DROP TABLE IF EXISTS item CASCADE;
2DROP TABLE if EXISTS inventory CASCADE;
3DROP TABLE if EXISTS loots CASCADE;
4
5CREATE TABLE item (
6 id SERIAL NOT NULL,
7 name VARCHAR(64) NOT NULL DEFAULT '',
8 rarity int NOT NULL DEFAULT 0,
9 icon_id int NOT NULL DEFAULT 0,
10 PRIMARY KEY (id)
11);
12
13CREATE TABLE inventory (
14 id SERIAL NOT NULL,
15 item_id int NOT NULL DEFAULT 0,
16 character_id int NOT NULL DEFAULT 0,
17 PRIMARY KEY (id),
18 FOREIGN KEY (item_id) REFERENCES item(id),
19 FOREIGN KEY (character_id) REFERENCES character(id)
20);
21
22CREATE TABLE loots (
23 id SERIAL NOT NULL,
24 item_id int NOT NULL DEFAULT 0,
25 creature_gid int NOT NULL DEFAULT 0,
26 PRIMARY KEY (id),
27 FOREIGN KEY (item_id) REFERENCES item(id),
28 FOREIGN KEY (creature_gid) REFERENCES creature(id)
29);