1 |
-- Catalogs |
begin; |
2 |
create table catalogs ( |
|
3 |
id serial, |
create table item_types( |
4 |
title text not null, |
name text not null, |
5 |
path text, |
primary key (name) |
|
date timestamp not null default now(), |
|
|
primary key(id) |
|
6 |
); |
); |
7 |
|
|
8 |
create table catalog_webarchive ( |
create table items ( |
9 |
uri text not null, -- unique index |
id SERIAL, |
10 |
last_crawled timestamp, |
name text not null, |
11 |
|
path text, -- index |
12 |
|
date timestamp not null default now(), |
13 |
|
type text not null references item_types(name), -- index |
14 |
primary key(id) |
primary key(id) |
15 |
) inherits (catalogs) ; |
); |
16 |
|
|
17 |
-- Entries in Catalog |
create table topic_types( |
18 |
create table entries ( |
name text not null, |
19 |
id serial, |
primary key (name) |
20 |
title text, |
); |
21 |
path text, |
|
22 |
date timestamp not null default now(), |
create table topics ( |
23 |
|
id SERIAL, |
24 |
|
name text, |
25 |
|
path text, |
26 |
|
date timestamp not null default now(), |
27 |
|
type text not null references topic_types(name), -- index |
28 |
|
parent_id integer references topics(id), -- index |
29 |
primary key(id) |
primary key(id) |
30 |
); |
); |
31 |
|
|
32 |
create table catalog_entry ( |
create table item_topics ( |
33 |
catalog_id int references catalogs(id), |
item_id integer references items(id) ON UPDATE CASCADE ON DELETE CASCADE, |
34 |
entry_id int references entries(id), |
topic_id integer references topics(id) ON UPDATE CASCADE ON DELETE CASCADE, |
35 |
e_type text not null, -- index |
PRIMARY KEY (item_id, topic_id) |
|
primary key (catalog_id, entry_id) |
|
36 |
); |
); |
37 |
|
|
38 |
-- Items for each Entry |
-- create inhertited topics and items |
39 |
create table items ( |
|
40 |
id serial, |
insert into topic_types values ('webarchive'); |
41 |
title text, |
create table topics_webarchive ( |
42 |
entry_id int references entries(id), |
uri text not null, -- unique index |
43 |
i_type text not null, |
last_crawled timestamp, |
|
date timestamp not null default now(), |
|
44 |
primary key(id) |
primary key(id) |
45 |
); |
) inherits (topics) ; |
46 |
|
|
47 |
-- HyperEstraier support table |
-- HyperEstraier support table |
48 |
create table items_est ( |
insert into item_types values ('est'); |
49 |
|
create table item_est ( |
50 |
path text, -- unique index |
path text, -- unique index |
51 |
uri text not null, -- unique index |
uri text not null, -- unique index |
52 |
size int, |
size int, |
53 |
primary key(id) |
primary key(id) |
54 |
) inherits (items) ; |
) inherits (items) ; |
55 |
|
|
|
-- Tags for Entries |
|
|
create table tags ( |
|
|
id serial, |
|
|
title text, -- index |
|
|
date timestamp not null default now(), |
|
|
primary key(id) |
|
|
); |
|
|
|
|
|
create table entry_tag ( |
|
|
entry_id int references entries(id), |
|
|
tag_id int references tags(id), |
|
|
value text not null, |
|
|
t_type text not null, -- index |
|
|
date timestamp not null default now(), |
|
|
primary key (entry_id, tag_id) |
|
|
); |
|
|
|
|
56 |
-- Pg General Bits |
-- Pg General Bits |
57 |
create table entries_pgbits ( |
insert into topic_types values ('pgbits'); |
58 |
|
create table topics_pgbits ( |
59 |
issue int not null, -- unique index |
issue int not null, -- unique index |
60 |
primary key(id) |
primary key(id) |
61 |
) inherits (entries) ; |
) inherits (topics) ; |
62 |
|
|
63 |
|
insert into item_types values ('pgbits'); |
64 |
create table items_pgbits ( |
create table items_pgbits ( |
65 |
mytitle text not null, |
mytitle text not null, |
66 |
ititle text not null, |
ititle text not null, |
69 |
contributors text, |
contributors text, |
70 |
primary key(id) |
primary key(id) |
71 |
) inherits (items) ; |
) inherits (items) ; |
|
|
|
|
-- some views |
|
|
|
|
|
create view pgbits_articles as select |
|
|
issue, |
|
|
date(entries_pgbits.date) as issue_date, |
|
|
ititle, |
|
|
mytitle, |
|
|
date(items_pgbits.date) as date |
|
|
from items_pgbits |
|
|
join entries_pgbits on entry_id = entries_pgbits.id ; |
|
|
|
|