CREATE TABLE objects (
	id SERIAL NOT NULL PRIMARY KEY,
	name VARCHAR(64) NOT NULL,
	description VARCHAR(255) NOT NULL,
	parent INTEGER REFERENCES objects(id),

	UNIQUE ( name, parent )
);

CREATE TABLE aclentries (
	object INTEGER NOT NULL REFERENCES objects(id),
	entity_type VARCHAR(5) NOT NULL CHECK ( entity_type IN ('group', 'user') ),
	entity VARCHAR(64) NOT NULL,
	allow VARCHAR(5) NOT NULL CHECK ( allow IN ('grant', 'deny') ),
	comment VARCHAR,

	UNIQUE ( object, entity_type, entity )
);
CREATE INDEX object_index ON aclentries ( object );

