-- Creazione tabella datacenter
CREATE TABLE IF NOT EXISTS datacenter (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL UNIQUE,
    path TEXT NOT NULL UNIQUE
);

-- Creazione tabella cluster
CREATE TABLE IF NOT EXISTS cluster (
    id INTEGER PRIMARY KEY,
    datacenter_id INTEGER NOT NULL,
    name TEXT NOT NULL,
    path TEXT NOT NULL,
    FOREIGN KEY(datacenter_id) REFERENCES datacenter(id)
);

-- Creazione tabella network
CREATE TABLE IF NOT EXISTS network (
    id INTEGER PRIMARY KEY,
    datacenter_id INTEGER NOT NULL,
    cluster_id INTEGER NOT NULL,
    name TEXT NOT NULL,
    path TEXT NOT NULL,
    FOREIGN KEY(datacenter_id) REFERENCES datacenter(id),
    FOREIGN KEY(cluster_id) REFERENCES cluster(id)
);

-- Creazione tabella datastore
CREATE TABLE IF NOT EXISTS datastore (
    id INTEGER PRIMARY KEY,
    datacenter_id INTEGER NOT NULL,
    name TEXT NOT NULL,
    path TEXT NOT NULL,
    capacity INTEGER NOT NULL,
    freespace INTEGER NOT NULL,
    type TEXT NOT NULL,
    FOREIGN KEY(datacenter_id) REFERENCES datacenter(id)
);
