CREATE SEQUENCE PMD_RUN_ID;
CREATE SEQUENCE PMD_VIOLATION_ID;
CREATE SEQUENCE PMD_METRICS_ID;

CREATE TABLE PMD_RUNS (
	RUN_ID INTEGER PRIMARY KEY,
	PROJECT_ID INTEGER,
	RUN_DATE DATETIME
);

CREATE TABLE PMD_VIOLATIONS (
	VIOLATION_ID INTEGER PRIMARY KEY,
	RUN_ID INTEGER REFERENCES PMD_RUNS(RUN_ID),
	RULE VARCHAR(100),
	FILENAME VARCHAR(100),
	LINE_NUMBER INTEGER,
	PACKAGE VARCHAR(100),
	CLASS VARCHAR(100),
	DESCRIPTION VARCHAR(255)
);

CREATE TABLE PMD_METRICS (
	METRIC_ID INTEGER PRIMARY KEY,
	RUN_ID INTEGER REFERENCES PMD_RUNS(RUN_ID),
	METRIC VARCHAR(100),
	LOW NUMERIC(10,2),
	HIGH NUMERIC(10,2),
	AVERAGE NUMERIC(10,2),
	DEVIATION NUMERIC(10,2)
);
