-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_schema.sql
51 lines (47 loc) · 1.33 KB
/
database_schema.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
-- 物品表
CREATE TABLE items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(100) NOT NULL,
type VARCHAR(50),
current_location_id INTEGER,
added_date DATE,
notes TEXT,
photo_url VARCHAR(255),
FOREIGN KEY (current_location_id) REFERENCES locations(id)
);
-- 位置表
CREATE TABLE locations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(100) NOT NULL,
parent_id INTEGER,
FOREIGN KEY (parent_id) REFERENCES locations(id)
);
-- 位置历史表
CREATE TABLE location_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER,
from_location_id INTEGER,
to_location_id INTEGER,
change_date DATETIME,
reason VARCHAR(100),
FOREIGN KEY (item_id) REFERENCES items(id),
FOREIGN KEY (from_location_id) REFERENCES locations(id),
FOREIGN KEY (to_location_id) REFERENCES locations(id)
);
-- 特殊物品信息表(如书籍、药品、电子产品)
CREATE TABLE special_item_info (
id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER,
key VARCHAR(50),
value TEXT,
FOREIGN KEY (item_id) REFERENCES items(id)
);
-- 提醒表
CREATE TABLE reminders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER,
reminder_type VARCHAR(50),
reminder_date DATE,
is_active BOOLEAN,
FOREIGN KEY (item_id) REFERENCES items(id)
);