CREATE RECURSIVE VIEW memorin.server_hierarchy (id,zone_id,core_count,ram,storage,data_center_id) AS (
    SELECT
        id,
        zone_id,
        core_count,
        ram,
        storage,
        id AS data_center_id
    FROM memorin.servers
    WHERE master_id IS NULL
    UNION ALL
    SELECT
        servers.id,
        servers.zone_id,
        servers.core_count,
        servers.ram,
        servers.storage,
        sh.data_center_id
    FROM memorin.servers
    INNER JOIN server_hierarchy AS sh
    ON sh.id = servers.master_id
);
