summaryrefslogtreecommitdiff
path: root/database/manytomany_sqlite.sql
blob: 2546b5fbcace5a56a32bae6af8dc7eb5440b5506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CREATE TABLE cds(
    id INTEGER PRIMARY KEY NOT NULL,
    title TEXT NOT NULL
);
CREATE TABLE artists(
    id INTEGER PRIMARY KEY NOT NULL,
    name TEXT NOT NULL
);
CREATE TABLE cds_and_artists(
    cds_id INTEGER,
    artists_id INTEGER,
    FOREIGN KEY(cds_id) REFERENCES cds(id) ON DELETE CASCADE,
    FOREIGN KEY(artists_id) REFERENCES artists(id) ON DELETE CASCADE
);
CREATE INDEX cdsindex ON cds_and_artists(cds_id);
CREATE INDEX artistsindex ON cds_and_artists(artists_id);