CREATE TABLE subnets (
    id INTEGER PRIMARY KEY NOT NULL,
    name TEXT NOT NULL,
    ifname TEXT NOT NULL,
    network TEXT NOT NULL,
    start_host INTEGER NOT NULL,
    end_host INTEGER NOT NULL,
    gateway4 INTEGER,
    dns TEXT,
    domain_name TEXT,
    vlan_id INTEGER
);

CREATE TABLE instances (
    id INTEGER PRIMARY KEY NOT NULL,
    name TEXT NOT NULL,
    mac_addr TEXT NOT NULL,
    subnet_id INTEGER NOT NULL,
    host_num INTEGER NOT NULL,
    ci_metadata TEXT NOT NULL,
    ci_userdata BINARY,
    UNIQUE(subnet_id, host_num),
    FOREIGN KEY(subnet_id) REFERENCES subnets(id)
);