CREATE TABLE IF NOT EXISTS [ServerSettings] ( [settingID] INTEGER PRIMARY KEY, [name] TEXT NOT NULL, [description] TEXT NOT NULL, [value] TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS [Users] ( [userID] INTEGER PRIMARY KEY, [name] TEXT NOT NULL, [email] TEXT, [authType] TEXT NOT NULL, [salt] TEXT, [hashedPWSalt] TEXT ); CREATE TABLE IF NOT EXISTS [MediaItems] ( [mediaID] INTEGER PRIMARY KEY, [userID] INTEGER NOT NULL, [EXIFDate] TEXT NOT NULL, [uploadDate] TEXT NOT NULL, [latitude] TEXT, [longitude] TEXT, [mediaType] INTEGER, /* 0 = Photo, 1 = Video */ [relPath] TEXT NOT NULL, FOREIGN KEY (userID) REFERENCES Users(userID) ); CREATE TABLE IF NOT EXISTS [Tags] ( [tagID] INTEGER PRIMARY KEY, [name] TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS [MediaTags] ( [mediaID] INTEGER NOT NULL, [tagID] INTEGER NOT NULL, FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID) FOREIGN KEY (tagID) REFERENCES Tags(tagID) ); CREATE TABLE IF NOT EXISTS [Albums] ( [albumID] INTEGER PRIMARY KEY, [userID] INTEGER NOT NULL, [name] TEXT NOT NULL, FOREIGN KEY (userID) REFERENCES Users(userID) ); CREATE TABLE IF NOT EXISTS [MediaAlbums] ( [mediaID] INTEGER NOT NULL, [albumID] INTEGER NOT NULL, FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID) FOREIGN KEY (albumID) REFERENCES Albums(albumID) );