CREATE TABLE IF NOT EXISTS locations
(
    id      text PRIMARY KEY,
    country text,
    city    text,
    region  text
);

CREATE TABLE IF NOT EXISTS providers
(
    id   integer PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL UNIQUE
);

CREATE TABLE IF NOT EXISTS prayer_times
(
    provider_id integer  NOT NULL REFERENCES providers (id),
    location_id text     NOT NULL REFERENCES locations (id),
    date        datetime NOT NULL,
    fajr        text     NOT NULL,
    sunrise     text     NOT NULL,
    dhuhr       text     NOT NULL,
    asr         text     NOT NULL,
    maghrib     text     NOT NULL,
    isha        text     NOT NULL
);

CREATE UNIQUE INDEX IF NOT EXISTS prayer_times__provider__location ON prayer_times (provider_id, location_id, date);