CREATE TABLE Author (
	   aid SERIAL PRIMARY KEY,
	   name VARCHAR
);

CREATE TABLE Document (
	   did SERIAL PRIMARY KEY,
	   title VARCHAR,
	   year INT
);

CREATE TABLE Word (
	   word VARCHAR PRIMARY KEY
);

CREATE TABLE Auth_Doc (
	   aid INT,
	   did INT,
	   PRIMARY KEY (aid, did),
	   FOREIGN KEY (aid) REFERENCES Author(aid),
	   FOREIGN KEY (did) REFERENCES Document(did)
);

CREATE TABLE Doc_Word (
	   did INT,
	   word VARCHAR,
	   FOREIGN KEY (did) REFERENCES Document(did),
	   FOREIGN KEY (word) REFERENCES Word(word)
);
