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
|
CREATE TABLE searchs (
id serial NOT NULL,
timestamp timestamp with time zone NOT NULL,
-- KadID of the source of the request
srcid integer NOT NULL,
-- KadID of the sybil that received the request
sybilid integer NOT NULL,
-- Kad ID of researched resource
targetid varchar(128) NOT NULL,
-- type of the resource addressed
-- 0: Kadv1 no type defined
-- 1: keyword
-- 2: file
type integer DEFAULT 0 NOT NULL,
-- Kad version of the request
version integer
);
ALTER TABLE ONLY searchs
ADD CONSTRAINT primary_searchs PRIMARY KEY (id);
-- the srcid is the id from the peers table
ALTER TABLE ONLY searchs
ADD CONSTRAINT searchs_foreign_srcid FOREIGN KEY (srcid) REFERENCES peers(id);
-- the sybilid is the id from the sybils table
ALTER TABLE ONLY searchs
ADD CONSTRAINT searchs_foreign_sybilid FOREIGN KEY (sybilid) REFERENCES sybils(id);
CREATE UNIQUE INDEX index_searchs_id ON searchs USING btree (id);
CREATE INDEX index_searchs_srcid ON searchs USING btree (srcid);
CREATE INDEX index_searchs_sybilid ON searchs USING btree (sybilid);
CREATE INDEX index_searchs_targetid ON searchs USING btree (targetid); |
Partager