BEGIN TRANSACTION;
CREATE TABLE `titles` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT,
	`bookid` INTEGER
);
CREATE TABLE `subjects` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);
CREATE TABLE `rights` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);
CREATE TABLE `publishers` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);
CREATE TABLE `languages` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);

CREATE TABLE `downloadlinkstype` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);

CREATE TABLE `downloadlinks` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT,
	`downloadtypeid`	INTEGER,
	`bookid` INTEGER
);
CREATE TABLE `bookshelves` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);
CREATE TABLE "books" (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`publisherid` INTEGER,
	`rightsid` INTEGER,
	`numdownloads` INTEGER,
	`gutenbergbookid` INTEGER
);
CREATE TABLE `book_subjects` (
	`bookid`	INTEGER,
	`subjectid`	INTEGER
);
CREATE TABLE `book_authors` (
	`bookid`	INTEGER,
	`authorid`	INTEGER
);
CREATE TABLE `book_languages` (
	`bookid`	INTEGER,
	`languageid`	INTEGER
);
CREATE TABLE `book_bookshelves` (
	`bookid`	INTEGER,
	`bookshelfid`	INTEGER
);
CREATE TABLE `authors` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
	`name`	TEXT
);
COMMIT;