-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase_schema.sql
More file actions
74 lines (62 loc) · 1.91 KB
/
database_schema.sql
File metadata and controls
74 lines (62 loc) · 1.91 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
CREATE TABLE community (
community_id uuid PRIMARY KEY,
name text,
handle character varying(256),
n_items integer,
n_bitstreams integer,
n_bytes bigint
);
CREATE TABLE collection (
collection_id uuid PRIMARY KEY,
name text,
handle character varying(256),
n_items integer,
n_bitstreams integer,
n_bytes bigint
);
CREATE TABLE item (
item_id uuid PRIMARY KEY,
name text,
handle character varying(256),
n_items integer,
n_bitstreams integer,
n_bytes bigint
);
CREATE TABLE community2community (
parent_comm_id uuid REFERENCES community(community_id),
child_comm_id uuid REFERENCES community(community_id)
);
CREATE TABLE community2collection (
community_id uuid REFERENCES community(community_id),
collection_id uuid REFERENCES collection(collection_id)
);
CREATE TABLE collection2item (
collection_id uuid REFERENCES collection(collection_id),
item_id uuid REFERENCES item(item_id)
);
CREATE TABLE item2bitstream (
item_id uuid REFERENCES item(item_id),
bitstream_id uuid
);
CREATE TABLE downloadspercommunity (
community_id uuid REFERENCES community(community_id),
"time" integer NOT NULL,
count integer DEFAULT 0 NOT NULL,
PRIMARY KEY(community_id, "time")
);
CREATE TABLE downloadspercollection (
collection_id uuid REFERENCES collection(collection_id),
"time" integer NOT NULL,
count integer DEFAULT 0 NOT NULL,
PRIMARY KEY(collection_id, "time")
);
CREATE TABLE downloadsperitem (
item_id uuid REFERENCES item(item_id),
"time" integer NOT NULL,
count integer DEFAULT 0 NOT NULL,
PRIMARY KEY(item_id, "time")
);
CREATE INDEX downloadsperitem_count_idx ON downloadsperitem USING btree (count);
CREATE INDEX item_handle_idx ON item USING btree (handle);
CREATE INDEX collection_handle_idx ON collection USING btree (handle);
CREATE INDEX community_handle_idx ON community USING btree (handle);