1 |
-- Catalogs |
2 |
create table catalogs ( |
3 |
id serial, |
4 |
title text not null, |
5 |
path text, |
6 |
date timestamp not null default now(), |
7 |
primary key(id) |
8 |
); |
9 |
|
10 |
create table catalog_webarchive ( |
11 |
uri text not null, -- unique index |
12 |
last_crawled timestamp, |
13 |
primary key(id) |
14 |
) inherits (catalogs) ; |
15 |
|
16 |
-- Entries in Catalog |
17 |
create table entries ( |
18 |
id serial, |
19 |
title text, |
20 |
path text, |
21 |
date timestamp not null default now(), |
22 |
primary key(id) |
23 |
); |
24 |
|
25 |
create table catalog_entry ( |
26 |
catalog_id int references catalogs(id), |
27 |
entry_id int references entries(id), |
28 |
e_type text not null, -- index |
29 |
primary key (catalog_id, entry_id) |
30 |
); |
31 |
|
32 |
-- Items for each Entry |
33 |
create table items ( |
34 |
id serial, |
35 |
title text, |
36 |
entry_id int references entries(id), |
37 |
i_type text not null, |
38 |
date timestamp not null default now(), |
39 |
primary key(id) |
40 |
); |
41 |
|
42 |
-- HyperEstraier support table |
43 |
create table items_est ( |
44 |
path text, -- unique index |
45 |
uri text not null, -- unique index |
46 |
size int, |
47 |
primary key(id) |
48 |
) inherits (items) ; |
49 |
|
50 |
-- Tags for Entries |
51 |
create table tags ( |
52 |
id serial, |
53 |
title text, -- index |
54 |
date timestamp not null default now(), |
55 |
primary key(id) |
56 |
); |
57 |
|
58 |
create table entry_tag ( |
59 |
entry_id int references entries(id), |
60 |
tag_id int references tags(id), |
61 |
value text not null, |
62 |
t_type text not null, -- index |
63 |
date timestamp not null default now(), |
64 |
primary key (entry_id, tag_id) |
65 |
); |
66 |
|
67 |
-- Pg General Bits |
68 |
create table entries_pgbits ( |
69 |
issue int not null, -- unique index |
70 |
primary key(id) |
71 |
) inherits (entries) ; |
72 |
|
73 |
create table items_pgbits ( |
74 |
mytitle text not null, |
75 |
ititle text not null, |
76 |
ikey text, |
77 |
html text, |
78 |
contributors text, |
79 |
primary key(id) |
80 |
) inherits (items) ; |
81 |
|
82 |
-- some views |
83 |
|
84 |
create view pgbits_articles as select |
85 |
issue, |
86 |
date(entries_pgbits.date) as issue_date, |
87 |
ititle, |
88 |
mytitle, |
89 |
date(items_pgbits.date) as date |
90 |
from items_pgbits |
91 |
join entries_pgbits on entry_id = entries_pgbits.id ; |
92 |
|