ocarina/design.txt

89 lines
2.5 KiB
Plaintext
Raw Normal View History

===============================================================================
= =
= Ocarina 6.0 =
= =
===============================================================================
My main goal for Ocarina 6.x is to stop writing my own solutions to problems
that have already been solved. For example, this means using SQL to store
a library rather than developing my own file format. This should help with
future maintenance because I'll have less code to navigate.
SQLite:
I plan on using SQLite for data storage as much as possible. I had
been using my own custom file formats for storing preferences or
libraries, but this is turning into a hassle as I have more code that
needs to be maintained. Try to use an SQLite prepared statement
whenever possible.
#include <sqlite3.h>
$ pkg-config --cflags --libs sqlite3
Files:
$HOME/.ocarina{-debug}/ocarina.db
Database: (ocarina.db)
Paths -
create table if not exists paths(
id INTEGER PRIMARY KEY AUTOINCREMENT,
filepath TEXT UNIQUE, /* root path of library */
enabled INTEGER, /* 0 = false, 1 = true */
);
Artist -
create table if not exists artists(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE
);
Album -
create table if not exists albums(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE,
year SHORT INTEGER,
);
Tracks -
create table if not exists tracks(
id INTEGER PRIMARY KEY AUTOINCREMENT,
FOREIGN KEY(path_id) REFERENCES paths(id),
FOREIGN KEY(artist_id) REFERENCES artists(id),
FOREIGN KEY(album_id) REFERENCES albums(id),
filepath TEXT UNIQUE, /* full path - libary root */
title TEXT,
comment TEXT,
genre TEXT,
lenstr TEXT,
track UNSIGNED INT,
count UNSIGNED INT DEFAULT 0,
last_day UNSIGNED INT DEFAULT 0,
last_month UNSIGNED INT DEFAULT 0,
last_year UNSIGNED INT DEFAULT 0,
length INT,
bitrate INT,
sample INT,
channels INT,
banned INT, /* 0 = false, 1 = true */
);
Playlist -
create table if not exists playlists(
id INTEGER PRIMARY KEY AUTOINCREMENT,
flags UNSIGNED INTEGER
)
Playlist #N -
create table if not exists playlist{0-9}(
FOREIGN KEY(track) REFERENCES tracks(id),
);
User settings -
create table if not exists config(
name PRIMARY KEY,
value INT,
);
Archlinux packages:
extra/sqlite