-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.sql
More file actions
executable file
·52 lines (46 loc) · 1.09 KB
/
tables.sql
File metadata and controls
executable file
·52 lines (46 loc) · 1.09 KB
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
-- file: u.user
create table user
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
age INTEGER,
gender VARCHAR(1),
occupation VARCHAR(32),
zipcode INTEGER
);
-- file: u.item
create table movie
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
releasedate DATE,
url TEXT
);
-- genres:
-- unknown, action, adventure, animation, childrens, comedy, crime, documentary, darama, fantasy, film-noir, horror, musical, mystery, romance, sci-fi, thriller, war, western
create table genre
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32)
);
-- many-to-many based on file: u.item "bitfield" at the end!
create table movie_genre
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
movieid INTEGER,
genreid INTEGER,
FOREIGN KEY (movieid) REFERENCES movie(id),
FOREIGN KEY (genreid) REFERENCES genre(id)
);
-- u.data
create table user_ratings
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
uid INTEGER,
mid INTEGER,
rating FLOAT,
timestamp TIMESTAMP,
FOREIGN KEY (uid) REFERENCES user,
FOREIGN KEY (mid) REFERENCES movie
);
-- index for movie_genre
create unique index idx_moviegenre on movie_genre (genreid,movieid);