BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "jobs" (
	"_id"	INTEGER NOT NULL UNIQUE,
	"title"	TEXT,
	"site"	TEXT,
	"url"	TEXT,
	"id"	TEXT UNIQUE,
	"summary"	TEXT,
	"company"	TEXT,
	"location"	TEXT,
	"postdate"	TEXT,
	"salary"	TEXT,
	"easyapply"	INTEGER,
	"timestamp"	INTEGER,
	PRIMARY KEY("_id" AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS "read" (
	"_id"	INTEGER NOT NULL UNIQUE,
	"rid"	INTEGER UNIQUE,
	"d"	INTEGER NOT NULL,
	FOREIGN KEY("rid") REFERENCES "jobs"("_id"),
	PRIMARY KEY("_id" AUTOINCREMENT)
);
CREATE VIEW jobsList as
select jobs._id, jobs.title, jobs.site, jobs.company, jobs.timestamp, read.d from jobs 
left join read on read.rid = jobs._id

order by jobs._id desc;
COMMIT;
