CREATE TABLE IF NOT EXISTS "youtube_meta" (
	"id"	TEXT NOT NULL,
	"title"	TEXT NOT NULL,
	"description"	TEXT,
	"uploader_name"	TEXT,
	"uploader_id"	TEXT,
	"duration"	INTEGER,
	"views"	INTEGER,
	"upload_date"	DATE,
	PRIMARY KEY("id")
);

CREATE TABLE IF NOT EXISTS "youtube_meta_tags" (
	"youtube_id" TEXT NOT NULL,
	"tag"	TEXT NOT NULL,
	PRIMARY KEY("youtube_id", "tag"),
	FOREIGN KEY("youtube_id") REFERENCES "youtube_meta"("id")
);

CREATE TABLE IF NOT EXISTS "youtube_meta_categories" (
	"youtube_id" TEXT NOT NULL,
	"category"	TEXT NOT NULL,
	PRIMARY KEY("youtube_id", "category"),
	FOREIGN KEY("youtube_id") REFERENCES "youtube_meta"("id")
);

CREATE TABLE IF NOT EXISTS "videos" (
	"sha256"	TEXT NOT NULL,
	"directory"	TEXT NOT NULL,
	"path"	TEXT NOT NULL,
	"duration" INTEGER,
	"title"	TEXT,
	"youtube_id" TEXT,
	PRIMARY KEY("sha256"),
	FOREIGN KEY("youtube_id") REFERENCES "youtube_meta"("id")
);
