1--
2-- PostgreSQL database dump
3--
4
5SET client_encoding = 'UTF8';
6SET standard_conforming_strings = off;
7SET check_function_bodies = false;
8SET client_min_messages = warning;
9SET escape_string_warning = off;
10
11SET SESSION AUTHORIZATION 'similar';
12
13--
14-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: similar
15--
16
17COMMENT ON SCHEMA public IS 'Standard public schema';
18
19
20SET search_path = public, pg_catalog;
21
22SET default_tablespace = '';
23
24SET default_with_oids = false;
25
26--
27-- Name: pictures; Type: TABLE; Schema: public; Owner: similar; Tablespace:
28--
29
30CREATE TABLE pictures (
31    id integer NOT NULL,
32    digest character(32) NOT NULL,
33    CONSTRAINT ck_digest CHECK ((char_length(digest) = 32))
34);
35
36
37--
38-- Name: pictures_id_seq; Type: SEQUENCE; Schema: public; Owner: similar
39--
40
41CREATE SEQUENCE pictures_id_seq
42    START WITH 1
43    INCREMENT BY 1
44    NO MAXVALUE
45    NO MINVALUE
46    CACHE 1;
47
48
49--
50-- Name: pictures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: similar
51--
52
53ALTER SEQUENCE pictures_id_seq OWNED BY pictures.id;
54
55
56--
57-- Name: sentpictures; Type: TABLE; Schema: public; Owner: similar; Tablespace:
58--
59
60CREATE TABLE sentpictures (
61    id integer NOT NULL,
62    url character varying(255) NOT NULL,
63    sender character varying(100) NOT NULL,
64    picture_id integer NOT NULL,
65    CONSTRAINT ck_url CHECK (((url)::text <> ''::text))
66);
67
68
69--
70-- Name: sentpictures_id_seq; Type: SEQUENCE; Schema: public; Owner: similar
71--
72
73CREATE SEQUENCE sentpictures_id_seq
74    START WITH 1
75    INCREMENT BY 1
76    NO MAXVALUE
77    NO MINVALUE
78    CACHE 1;
79
80
81--
82-- Name: sentpictures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: similar
83--
84
85ALTER SEQUENCE sentpictures_id_seq OWNED BY sentpictures.id;
86
87
88--
89-- Name: signatures; Type: TABLE; Schema: public; Owner: similar; Tablespace:
90--
91
92CREATE TABLE signatures (
93    id integer NOT NULL,
94    compressed_signature bytea NOT NULL,
95    picture_id integer NOT NULL,
96    CONSTRAINT ck_signature CHECK ((octet_length(compressed_signature) >= 182))
97);
98
99
100--
101-- Name: signatures_id_seq; Type: SEQUENCE; Schema: public; Owner: similar
102--
103
104CREATE SEQUENCE signatures_id_seq
105    START WITH 1
106    INCREMENT BY 1
107    NO MAXVALUE
108    NO MINVALUE
109    CACHE 1;
110
111
112--
113-- Name: signatures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: similar
114--
115
116ALTER SEQUENCE signatures_id_seq OWNED BY signatures.id;
117
118
119--
120-- Name: words; Type: TABLE; Schema: public; Owner: similar; Tablespace:
121--
122
123CREATE TABLE words (
124    pos_and_word bytea NOT NULL,
125    signature_id integer NOT NULL,
126    CONSTRAINT ck_pos_and_word CHECK ((octet_length(pos_and_word) >= 2))
127);
128
129
130--
131-- Name: id; Type: DEFAULT; Schema: public; Owner: similar
132--
133
134ALTER TABLE pictures ALTER COLUMN id SET DEFAULT nextval('pictures_id_seq'::regclass);
135
136
137--
138-- Name: id; Type: DEFAULT; Schema: public; Owner: similar
139--
140
141ALTER TABLE sentpictures ALTER COLUMN id SET DEFAULT nextval('sentpictures_id_seq'::regclass);
142
143
144--
145-- Name: id; Type: DEFAULT; Schema: public; Owner: similar
146--
147
148ALTER TABLE signatures ALTER COLUMN id SET DEFAULT nextval('signatures_id_seq'::regclass);
149
150
151--
152-- Name: pictures_pkey; Type: CONSTRAINT; Schema: public; Owner: similar; Tablespace:
153--
154
155ALTER TABLE ONLY pictures
156    ADD CONSTRAINT pictures_pkey PRIMARY KEY (id);
157
158
159--
160-- Name: sentpictures_pkey; Type: CONSTRAINT; Schema: public; Owner: similar; Tablespace:
161--
162
163ALTER TABLE ONLY sentpictures
164    ADD CONSTRAINT sentpictures_pkey PRIMARY KEY (id);
165
166
167--
168-- Name: signatures_pkey; Type: CONSTRAINT; Schema: public; Owner: similar; Tablespace:
169--
170
171ALTER TABLE ONLY signatures
172    ADD CONSTRAINT signatures_pkey PRIMARY KEY (id);
173
174
175--
176-- Name: idx_digest; Type: INDEX; Schema: public; Owner: similar; Tablespace:
177--
178
179CREATE UNIQUE INDEX idx_digest ON pictures USING btree (digest);
180
181
182--
183-- Name: idx_picture_id; Type: INDEX; Schema: public; Owner: similar; Tablespace:
184--
185
186CREATE INDEX idx_picture_id ON sentpictures USING btree (picture_id);
187
188
189--
190-- Name: idx_pos_and_word; Type: INDEX; Schema: public; Owner: similar; Tablespace:
191--
192
193CREATE INDEX idx_pos_and_word ON words USING btree (pos_and_word);
194
195
196--
197-- Name: idx_url; Type: INDEX; Schema: public; Owner: similar; Tablespace:
198--
199
200CREATE UNIQUE INDEX idx_url ON sentpictures USING btree (url);
201
202
203--
204-- Name: sentpictures_picture_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: similar
205--
206
207ALTER TABLE ONLY sentpictures
208    ADD CONSTRAINT sentpictures_picture_id_fkey FOREIGN KEY (picture_id) REFERENCES pictures(id) ON UPDATE CASCADE ON DELETE CASCADE;
209
210
211--
212-- Name: signatures_picture_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: similar
213--
214
215ALTER TABLE ONLY signatures
216    ADD CONSTRAINT signatures_picture_id_fkey FOREIGN KEY (picture_id) REFERENCES pictures(id) ON UPDATE CASCADE ON DELETE CASCADE;
217
218
219--
220-- Name: words_signature_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: similar
221--
222
223ALTER TABLE ONLY words
224    ADD CONSTRAINT words_signature_id_fkey FOREIGN KEY (signature_id) REFERENCES signatures(id) ON UPDATE CASCADE ON DELETE CASCADE;
225
226
227--
228-- PostgreSQL database dump complete
229--
230
231