3 * Copyright (C) 2007, Rus V. Brushkoff, All rights reserved.
8 create database '/usr/local/sfinx/sfinx.fdb' user 'sysdba' password 'harbour' page_size 16384 default character set koi8r;
10 create table objects (
12 name VARCHAR(64) not null,
13 description VARCHAR(256) not null,
14 /* TODO: ÉÍÑ ÔÁÂÌÉÃÙ Ó ÏÐÉÓÁÎÉÅÍ ÐÏÌÅÊ É Ô.Ä. */
15 constraint pkobjects PRIMARY KEY (id),
19 insert into objects (id, name, description) values (1, 'slice', 'User defined abstraction');
20 insert into objects (id, name, description) values (2, 'file', 'Any file, containing some data');
21 insert into objects (id, name, description) values (3, 'note', 'Note about smth.');
22 insert into objects (id, name, description) values (4, 'event', 'Event');
23 insert into objects (id, name, description) values (5, 'contact', 'Contact');
24 insert into objects (id, name, description) values (6, 'task', 'Task or plan');
25 insert into objects (id, name, description) values (7, 'message', 'Mail or IM');
26 insert into objects (id, name, description) values (8, 'knowledge', 'Knowledge / kh [ know how ]');
28 /* TODO: rule / intention / aim / dream */
30 create sequence slice_id;
31 set generator slice_id to 0;
33 /* slices - ÔÁÂÌÉÃÁ ËÁÔÅÇÏÒÉÊ/ÓÒÅÚÏ×/ÁÂÓÔÒÁËÃÉÊ. Slice ÏÔÌÉÞÁÅÔÓÑ ÏÔ ÏÓÔÁÌØÎÙÈ
34 ÏÂØÅËÔÏ× ÏÔÓÔÕÔÓÔ×ÉÅÍ ÇÌÁ×ÎÏÊ Ó×ÑÚÉ, Ô.Å. Ñ×ÌÑÅÔÓÑ ÉÚÎÁÞÁÌØÎÙÍ [ Dao ] É
35 ÍÏÖÅÔ ÓÕÝÅÓÔ×Ï×ÁÔØ ÓÁÍ ÐÏ-ÓÅÂÅ. óÌÁÊÓÙ ÉÍÅÀÔ ÄÒÅ×Ï×ÉÄÎÕÀ ÓÔÒÕËÔÕÒÕ, ÐÏËÁ ÂÅÚ
36 ÍÎÏÖÅÓÔ×ÅÎÎÏÇÏ ÎÁÓÌÅÄÏ×ÁÎÉÑ
42 parent_id BIGINT not null,
43 name VARCHAR(64) not null,
44 description VARCHAR(256) not null,
45 /* ÄÉÒÅËÔÏÒÉÑ ÄÌÑ ÏÔÓÏÒÔÉÒÏ×ÁÎÎÙÈ ÆÁÊÌÏ× */
46 directory VARCHAR(256),
48 ctime timestamp default 'now',
50 etime timestamp default 'now',
51 constraint pkslices PRIMARY KEY (id),
52 UNIQUE (parent_id, name)
55 create index slices_etime on slices(etime);
56 create index slices_ctime on slices(ctime);
60 /* ÕÎÉ×ÅÒÓÁÌØÎÙÊ ÔÒÉÇÇÅÒ: firebird >= 2.x ËÁÖÉÓØ */
62 create trigger slice_trg for slices
63 active before insert or update position 0
66 if (new.id is null) then
67 new.id = gen_id(slice_id, 1);
68 select cast('now' as timestamp) from rdb$database into new.etime;
74 insert into slices (parent_id, name, description) values (0, 'Root', 'Dao Slice');
75 insert into slices (parent_id, name, description, directory) values (1, 'Texts', 'ôÅËÓÔÙ, äÏËÉ', 'Texts');
76 insert into slices (parent_id, name, description, directory) values (1, 'Images', 'ëÁÒÔÉÎËÉ', 'Images');
77 insert into slices (parent_id, name, description, directory) values (1, 'Music', 'íÕÚÙËÁ, MP3', 'Music');
79 /* module_conf - ÎÁÓÔÒÏÊËÉ ÍÏÄÕÌÅÊ */
81 create table files_module_conf (
82 unsorted_files_path VARCHAR(256),
83 sorted_file_tree VARCHAR(256),
84 desc_file_name VARCHAR(256),
85 desc_file_enable SMALLINT,
86 detect_mime_type SMALLINT
89 insert into files_module_conf (unsorted_files_path, sorted_file_tree, desc_file_name, desc_file_enable) values ('/Arhiv/unsorted', '/Arhiv/sorted', 'description.txt', 1);
91 create sequence file_id;
92 set generator file_id to 0;
98 name VARCHAR(256) not null,
100 /* Á×ÔÏÒ/ÉÚÄÁÔÅÌØÓÔ×Ï */
101 authority VARCHAR(512),
102 description VARCHAR(1024),
103 comments VARCHAR(1024),
106 /* is_directory SMALLINT default 0, */
107 /* ÅÓÌÉ ÆÁÊÌ ÌÅÖÉÔ × ËÁËÏÊ-ÎÉÔØ ÄÉÒÅËÔÏÒÉÉ */
108 /* parent_file_id INTEGER default 0, */
110 /* ÄÁÔÁ ÚÁÎÅÓÅÎÉÑ ÆÁÊÌÁ × ÂÁÚÕ */
111 ctime timestamp default 'now',
112 /* ÄÁÔÁ ÉÚÍÅÎÅÎÉÑ ÉÎÆÙ Ï ÆÁÊÌÅ × ÂÁÚÅ */
113 etime timestamp default 'now',
115 /* ÔÉÐ ÇÌÁ×ÎÏÇÏ ÏÂØÅËÔÁ (main object) Ó ËÏÔÏÒÙÍ ÁÓÓÏÃÉÉÒÏ×ÁÎ ÆÁÊÌ */
116 mtag_type INTEGER not null,
118 mtag_id BIGINT not null,
119 /* ÌÀÂÁÑ ÉÅÒÁÒÈÉÑ ÏÂØÅËÔÏ× ÉÍÅÅÔ Ó×ÏÊ ÇÌÁ×ÎÙÊ ÓÌÁÊÓ-ÒÏÄÉÔÅÌØ
120 ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÂÙÓÔÒÏÊ ×ÙÂÏÒËÉ ×ÎÕÔÒÉ ÓÌÁÊÓÁ
122 mtag_slice_id BIGINT not null,
124 fsize BIGINT default 0,
126 fsize_compressed BIGINT default 0,
127 sha256_compressed VARCHAR(64),
129 /* ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÊ ÐÒÏ×ÅÒËÉ ËÏÎÔÒ. ÓÕÍÍÙ */
130 csum_last_checked timestamp default '01.01.1900 00:00:00',
131 csum_valid SMALLINT default 0,
133 /* ÔÉÐ ÐÒÏ×ÅÒËÉ ÆÁÊÌÁ :
137 /* check_type SMALLINT default 0, */
139 store_in_sorted_location SMALLINT default 0,
141 /* mimetype INTEGER default 0, */
143 /* mime ÔÉÐ ÄÌÑ ÈÒÁÎÅÎÉÑ × ÕÐÁËÏ×ÁÎÎÏÍ ×ÉÄÅ */
144 /* compress_mimetype INTEGER default 0, */
145 /* full_index SMALLINT default 0, */
146 /* added_by_uid INTEGER not null */
148 constraint pkfiles PRIMARY KEY (id),
149 UNIQUE (mtag_id, mtag_type, name)
152 create index files_etime on files(etime);
153 create index files_ctime on files(ctime);
154 create index files_name on files(name);
155 create index files_title on files(title);
156 create index files_auth on files(authority);
157 create index files_desc on files(description);
158 create index files_comm on files(comments);
162 create trigger file_trg for files
163 active before insert or update position 0
166 if (new.id is null) then
167 new.id = gen_id(file_id, 1);
168 select cast('now' as timestamp) from rdb$database into new.etime;
174 /* ÄÏÐ-ÔÁÂÌÉÃÁ Ó×ÑÚÉ ÆÁÊÌÏ× É ÏÂØÅËÔÏ× */
176 create table file_tags (
180 constraint pkfile_slices PRIMARY KEY (file_id, obj_id, obj_type)
183 create sequence note_id;
184 set generator note_id to 0;
189 name VARCHAR(256) not null,
193 /* ÄÁÔÁ ÚÁÎÅÓÅÎÉÑ × ÂÁÚÕ */
194 ctime timestamp default 'now',
195 /* ÄÁÔÁ ÉÚÍÅÎÅÎÉÑ ÉÎÆÙ × ÂÁÚÅ */
196 etime timestamp default 'now',
198 mtag_type INTEGER not null,
199 mtag_id BIGINT not null,
200 mtag_slice_id BIGINT not null,
202 /* text field is crypted */
203 secured SMALLINT default 0,
205 constraint pknotes PRIMARY KEY (id),
206 UNIQUE (mtag_slice_id, mtag_type, mtag_id, name),
210 create index notes_etime on notes(etime);
211 create index notes_ctime on notes(ctime);
212 create index notes_name on notes(name);
213 create index notes_url on notes(url);
215 /* ÅÓÌÉ Ë ÐÒÉÍÅÒÕ text crypted - ÉÎÄÅËÓ ÎÅ ÎÕÖÅÎ: ÉÎÔÅÒÅÓÎÏ ÅÓÔØ ÌÉ ÔÁËÁÑ
216 ÆÉÇÎÑ ËÁË ÕÓÌÏ×ÎÙÊ ÉÎÄÅËÓ - ÉÎÄÅËÓÉÒÏ×ÁÔØ ÔÏÌØËÏ ÞÁÓÔØ ÔÁÂÌÉÃÙ ÐÏ ÕÓÌÏ×ÉÀ
217 ËÁËÉÈ-ÌÉÂÏ ÐÏÌÅÊ × ÔÅËÕÝÅÍ row ? */
218 /* create index notes_text on notes(text); */
222 create trigger note_trg for notes
223 active before insert or update position 0
226 if (new.id is null) then
227 new.id = gen_id(note_id, 1);
228 select cast('now' as timestamp) from rdb$database into new.etime;
234 insert into notes (id, name, url, text, mtag_id, mtag_type, mtag_slice_id) values (1, 'sample note', 'some name', 'some url', 3, 1, 3);
236 /* ÄÏÐ-ÔÁÂÌÉÃÁ note-Ó×ÑÚÅÊ */
238 create table note_tags (
242 constraint pknote_slices PRIMARY KEY (note_id, obj_id, obj_type)
250 - ÔÁÂÌÉÃÁ ÒÅÊÔÉÎÇÏ× ÄÌÑ ÏÂØÅËÔÏ× (files/notes/events/contacts/etc.)
251 - ÔÁÂÌÉÃÁ ÓÔÁÔÉÓÔÉËÉ ÄÌÑ ÄÅÍÏÎÁ (ËÏÌ. ËÏÎÎÅËÔÏ×/ÏÂØÅÍÙ ÉÎÆÙ/etc.)