CREATE TABLE meta_aliases (
	id UUID DEFAULT gen_random_uuid(),
	document BPCHAR NOT NULL,
	pattern BPCHAR NOT NULL,
	alias BPCHAR NOT NULL,
	
	CONSTRAINT unique_aliases UNIQUE (alias),
	PRIMARY KEY (id)
);

CREATE TABLE meta_links (
	id UUID DEFAULT gen_random_uuid(),
	document BPCHAR NOT NULL,
	pattern BPCHAR NOT NULL,
	rel BPCHAR NOT NULL,
	type BPCHAR,
	href BPCHAR,
	
	PRIMARY KEY (id)
);

CREATE TABLE meta_link_properties (
	id UUID DEFAULT gen_random_uuid(),
	meta_link_id UUID REFERENCES meta_links (id) NOT NULL,
	rel BPCHAR NOT NULL,
	value BPCHAR,
	
	PRIMARY KEY (id)
);

CREATE TABLE meta_properties (
	id UUID DEFAULT gen_random_uuid(),
	document BPCHAR NOT NULL,
	pattern BPCHAR NOT NULL,
	rel BPCHAR NOT NULL,
	value BPCHAR,
	
	PRIMARY KEY (id)
);
