{"artists": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "name", "VARCHAR(120)", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "sqlite_sequence": {"columns": [[0, "name", "", 0, null, 0], [1, "seq", "", 0, null, 0]], "primary_keys": [], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "albums": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "title", "VARCHAR(160)", 1, null, 0], [2, "artist_id", "INTEGER", 1, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "artists", "artist_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "employees": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "last_name", "VARCHAR(20)", 1, null, 0], [2, "first_name", "VARCHAR(20)", 1, null, 0], [3, "title", "VARCHAR(30)", 0, null, 0], [4, "reports_to", "INTEGER", 0, null, 0], [5, "birth_date", "TIMESTAMP", 0, null, 0], [6, "hire_date", "TIMESTAMP", 0, null, 0], [7, "address", "VARCHAR(70)", 0, null, 0], [8, "city", "VARCHAR(40)", 0, null, 0], [9, "state", "VARCHAR(40)", 0, null, 0], [10, "country", "VARCHAR(40)", 0, null, 0], [11, "postal_code", "VARCHAR(10)", 0, null, 0], [12, "phone", "VARCHAR(24)", 0, null, 0], [13, "fax", "VARCHAR(24)", 0, null, 0], [14, "email", "VARCHAR(60)", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "employees", "reports_to", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "customers": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "first_name", "VARCHAR(40)", 1, null, 0], [2, "last_name", "VARCHAR(20)", 1, null, 0], [3, "company", "VARCHAR(80)", 0, null, 0], [4, "address", "VARCHAR(70)", 0, null, 0], [5, "city", "VARCHAR(40)", 0, null, 0], [6, "state", "VARCHAR(40)", 0, null, 0], [7, "country", "VARCHAR(40)", 0, null, 0], [8, "postal_code", "VARCHAR(10)", 0, null, 0], [9, "phone", "VARCHAR(24)", 0, null, 0], [10, "fax", "VARCHAR(24)", 0, null, 0], [11, "email", "VARCHAR(60)", 1, null, 0], [12, "support_rep_id", "INTEGER", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "employees", "support_rep_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "genres": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "name", "VARCHAR(120)", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "invoices": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "customer_id", "INTEGER", 1, null, 0], [2, "invoice_date", "TIMESTAMP", 1, null, 0], [3, "billing_address", "VARCHAR(70)", 0, null, 0], [4, "billing_city", "VARCHAR(40)", 0, null, 0], [5, "billing_state", "VARCHAR(40)", 0, null, 0], [6, "billing_country", "VARCHAR(40)", 0, null, 0], [7, "billing_postal_code", "VARCHAR(10)", 0, null, 0], [8, "total", "NUMERIC(10,2)", 1, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "customers", "customer_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "media_types": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "name", "VARCHAR(120)", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "tracks": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "name", "VARCHAR(200)", 1, null, 0], [2, "album_id", "INTEGER", 0, null, 0], [3, "media_type_id", "INTEGER", 1, null, 0], [4, "genre_id", "INTEGER", 0, null, 0], [5, "composer", "VARCHAR(220)", 0, null, 0], [6, "milliseconds", "INTEGER", 1, null, 0], [7, "bytes", "INTEGER", 0, null, 0], [8, "unit_price", "NUMERIC(10,2)", 1, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "media_types", "media_type_id", "id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "genres", "genre_id", "id", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "albums", "album_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "invoice_lines": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "invoice_id", "INTEGER", 1, null, 0], [2, "track_id", "INTEGER", 1, null, 0], [3, "unit_price", "NUMERIC(10,2)", 1, null, 0], [4, "quantity", "INTEGER", 1, null, 0]], "primary_keys": ["id"], "foreign_keys": [[0, 0, "tracks", "track_id", "id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "invoices", "invoice_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "playlists": {"columns": [[0, "id", "INTEGER", 0, null, 1], [1, "name", "VARCHAR(120)", 0, null, 0]], "primary_keys": ["id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "id"]]], "check_constraints": []}, "playlist_tracks": {"columns": [[0, "playlist_id", "INTEGER", 1, null, 1], [1, "track_id", "INTEGER", 1, null, 2]], "primary_keys": ["playlist_id", "track_id"], "foreign_keys": [[0, 0, "tracks", "track_id", "id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "playlists", "playlist_id", "id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "playlist_id"], [1, 1, "track_id"]], [[0, 0, "playlist_id"], [1, 1, "track_id"]]], "check_constraints": []}}
CREATE TABLE artists (
    id INTEGER   PRIMARY KEY,
    name VARCHAR(120),
    UNIQUE (id)
);

CREATE TABLE sqlite_sequence (
    name,
    seq
);

CREATE TABLE albums (
    id INTEGER   PRIMARY KEY,
    title VARCHAR(160) NOT NULL,
    artist_id INTEGER NOT NULL,
    UNIQUE (id),
    FOREIGN KEY (artist_id) REFERENCES artists(id)
);

CREATE TABLE employees (
    id INTEGER   PRIMARY KEY,
    last_name VARCHAR(20) NOT NULL,
    first_name VARCHAR(20) NOT NULL,
    title VARCHAR(30),
    reports_to INTEGER,
    birth_date TIMESTAMP,
    hire_date TIMESTAMP,
    address VARCHAR(70),
    city VARCHAR(40),
    state VARCHAR(40),
    country VARCHAR(40),
    postal_code VARCHAR(10),
    phone VARCHAR(24),
    fax VARCHAR(24),
    email VARCHAR(60),
    UNIQUE (id),
    FOREIGN KEY (reports_to) REFERENCES employees(id)
);

CREATE TABLE customers (
    id INTEGER   PRIMARY KEY,
    first_name VARCHAR(40) NOT NULL,
    last_name VARCHAR(20) NOT NULL,
    company VARCHAR(80),
    address VARCHAR(70),
    city VARCHAR(40),
    state VARCHAR(40),
    country VARCHAR(40),
    postal_code VARCHAR(10),
    phone VARCHAR(24),
    fax VARCHAR(24),
    email VARCHAR(60) NOT NULL,
    support_rep_id INTEGER,
    UNIQUE (id),
    FOREIGN KEY (support_rep_id) REFERENCES employees(id)
);

CREATE TABLE genres (
    id INTEGER   PRIMARY KEY,
    name VARCHAR(120),
    UNIQUE (id)
);

CREATE TABLE invoices (
    id INTEGER   PRIMARY KEY,
    customer_id INTEGER NOT NULL,
    invoice_date TIMESTAMP NOT NULL,
    billing_address VARCHAR(70),
    billing_city VARCHAR(40),
    billing_state VARCHAR(40),
    billing_country VARCHAR(40),
    billing_postal_code VARCHAR(10),
    total NUMERIC(10,2) NOT NULL,
    UNIQUE (id),
    FOREIGN KEY (customer_id) REFERENCES customers(id)
);

CREATE TABLE media_types (
    id INTEGER   PRIMARY KEY,
    name VARCHAR(120),
    UNIQUE (id)
);

CREATE TABLE tracks (
    id INTEGER   PRIMARY KEY,
    name VARCHAR(200) NOT NULL,
    album_id INTEGER,
    media_type_id INTEGER NOT NULL,
    genre_id INTEGER,
    composer VARCHAR(220),
    milliseconds INTEGER NOT NULL,
    bytes INTEGER,
    unit_price NUMERIC(10,2) NOT NULL,
    UNIQUE (id),
    FOREIGN KEY (media_type_id) REFERENCES media_types(id),
    FOREIGN KEY (genre_id) REFERENCES genres(id),
    FOREIGN KEY (album_id) REFERENCES albums(id)
);

CREATE TABLE invoice_lines (
    id INTEGER   PRIMARY KEY,
    invoice_id INTEGER NOT NULL,
    track_id INTEGER NOT NULL,
    unit_price NUMERIC(10,2) NOT NULL,
    quantity INTEGER NOT NULL,
    UNIQUE (id),
    FOREIGN KEY (track_id) REFERENCES tracks(id),
    FOREIGN KEY (invoice_id) REFERENCES invoices(id)
);

CREATE TABLE playlists (
    id INTEGER   PRIMARY KEY,
    name VARCHAR(120),
    UNIQUE (id)
);

CREATE TABLE playlist_tracks (
    playlist_id INTEGER NOT NULL  PRIMARY KEY,
    track_id INTEGER NOT NULL  PRIMARY KEY,
    PRIMARY KEY (playlist_id, track_id),
    UNIQUE (playlist_id, track_id),
    UNIQUE (playlist_id, track_id),
    FOREIGN KEY (track_id) REFERENCES tracks(id),
    FOREIGN KEY (playlist_id) REFERENCES playlists(id)
);