-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
32 lines (32 loc) · 995 Bytes
/
db.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
-- categories(pk: id, name)
CREATE TABLE IF NOT EXISTS categories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
-- sources(pk:id,name,url,fk:category_id)
CREATE TABLE IF NOT EXISTS sources (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
url TEXT NOT NULL,
category_id INTEGER NOT NULL,
FOREIGN KEY (category_id) REFERENCES categories(id)
);
-- items(pk:id,title,content,url,fk:source_id)
CREATE TABLE IF NOT EXISTS items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT NOT NULL,
url TEXT NOT NULL,
node TEXT NOT NULL,
date DATE NULL,
readed BOOLEAN NOT NULL DEFAULT 0,
source_id INTEGER NOT NULL,
FOREIGN KEY (source_id) REFERENCES sources(id)
);
-- mapping(pk:id, config,fk:source_id)
CREATE TABLE IF NOT EXISTS mapping (
id INTEGER PRIMARY KEY AUTOINCREMENT,
config TEXT NOT NULL,
source_id INTEGER NOT NULL,
FOREIGN KEY (source_id) REFERENCES sources(id)
);