CREATE TABLE package (		-- binary Debian packages
	id INTEGER PRIMARY KEY,
	name TEXT UNIQUE NOT NULL,
	-- binary package name
	version TEXT,		-- Debian version
	architecture TEXT,
	source TEXT);		-- name of the source package it was built from

CREATE TABLE dependency (	-- binary package dependencies
	pid INTEGER NOT NULL REFERENCES package(id) ON DELETE CASCADE,
	-- the package that carries a Depends: header
	required TEXT NOT NULL);
	-- the name of a package that is depended upon without alternative

CREATE VIRTUAL TABLE controlcontent USING fts4(content);

CREATE TABLE control (		-- control.tar contents
	pid INTEGER NOT NULL REFERENCES package(id) ON DELETE CASCADE,
	-- the package that contains a control.tar member
	name TEXT NOT NULL,
	-- the name of the control.tar member without leading "./"
	cid INTEGER NOT NULL);
	-- a reference to the binary contents of the file

CREATE INDEX control_name_index ON control(name);
