CREATE TABLE IF NOT EXISTS songs(
	id INTEGER AUTOINCREMENT, 
	name VARCHAR(100), 
	size INT NOT NULL,
	data BLOB NOT NULL,
	PRIMARY KEY(id)

);

CREATE UNIQUE INDEX IF NOT EXISTS isongs ON songs(name,size);

CREATE TABLE IF NOT EXISTS playlists(
	id INTEGER AUTOINCREMENT,
	name VARCHAR(50) NOT NULL UNIQUE,
	description VARCHAR(1000) DEFAULT NULL,
	image BLOB DEFAULT NULL,
	PRIMARY KEY(id)
);

CREATE TABLE IF NOT EXISTS playlistsdata(
	playlist INT NOT NULL,
	song INT NOT NULL,
	FOREIGN KEY(playlist) REFERENCES playlists(id)
        ON UPDATE CASCADE
		ON DELETE CASCADE,
	FOREIGN KEY(song) REFERENCES songs(id)
        ON UPDATE CASCADE
		ON DELETE CASCADE
);

CREATE UNIQUE INDEX IF NOT EXISTS iplaylistsdata ON playlistsdata(playlist,song);


