This repository has been archived by the owner on Feb 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.sql
50 lines (44 loc) · 2.81 KB
/
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
CREATE TABLE IF NOT EXISTS user (id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS item (id TEXT NOT NULL PRIMARY KEY,
title TEXT,
description TEXT,
price REAL,
imageUrl TEXT,
salesCategory TEXT,
salesRank INTEGER,
overallRating REAL);
CREATE TABLE IF NOT EXISTS review (id INTEGER NOT NULL PRIMARY KEY,
userId TEXT NOT NULL,
itemId TEXT NOT NULL,
rating INTEGER NOT NULL,
reviewTime INTEGER,
FOREIGN KEY (userId) REFERENCES user(id),
FOREIGN KEY (itemId) REFERENCES item(id));
CREATE TABLE IF NOT EXISTS item_related_list (itemId TEXT NOT NULL,
relatedItemId TEXT NOT NULL,
relation TEXT,
FOREIGN KEY (relatedItemId) REFERENCES item(id),
FOREIGN KEY (itemId) REFERENCES item(id));
CREATE TABLE IF NOT EXISTS category (id INTEGER NOT NULL PRIMARY KEY,
parentCategoryId INTEGER,
namespace TEXT UNIQUE,
name TEXT NOT NULL,
FOREIGN KEY (parentCategoryId) REFERENCES category(id));
CREATE TABLE IF NOT EXISTS item_category_list (itemId TEXT NOT NULL,
categoryId INTEGER NOT NULL,
FOREIGN KEY (itemId) REFERENCES item(id),
FOREIGN KEY (categoryId) REFERENCES category(id));
CREATE TABLE IF NOT EXISTS algo_evaluation (id INTEGER NOT NULL PRIMARY KEY,
itemId TEXT NOT NULL,
random INT,
relatedAll INT,
relatedAlsoBought INT,
relatedAlsoViewed INT,
sameCategory INT,
siblingCategory INT,
collaborativeFiltering INT,
contentBased INT,
contentBasedWithCategory INT,
TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (itemId) REFERENCES item(id));