January 2020
Intermediate to advanced
640 pages
16h 56m
English
Setting up the tables we need for the CockroachDB graph implementation is a fairly straightforward process. The following is a combined list of the SQL statements that will be applied when we run the included DB migrations:
CREATE TABLE IF NOT EXISTS links ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), url STRING UNIQUE, retrieved_at TIMESTAMP ); CREATE TABLE IF NOT EXISTS edges ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), src UUID NOT NULL REFERENCES links(id) ON DELETE CASCADE, dst UUID NOT NULL REFERENCES links(id) ON DELETE CASCADE, updated_at TIMESTAMP, CONSTRAINT edge_links UNIQUE(src,dst) );
You probably noticed that, while building the in-memory graph implementation, ...