## Modelado de Data Vault en el IDE de asapBI: Hubs, Links y Satellites
El IDE de asapBI, como plugin para VSCode o Theia, simplifica la creación de estructuras de Data Vault. El árbol de la izquierda muestra bases de datos (NORD, ASGARD), esquemas (repo_md, repo_fi), carpetas (ODS, DDS) y objetos como hubs (sales_hub). Greenplum está soportado mediante el módulo de generación de SQL. Tarea: En el esquema FI, crear una carpeta DEMO con dos hubs, satellites y un link entre ellos.
Creación de Estructuras de Carpetas
Pasa el ratón sobre un esquema o carpeta: aparece la opción para una nueva carpeta. Especifica el nombre y el paquete de despliegue (test, prod). Para objetos temporales, deja el valor predeterminado.
La carpeta terminada se integra en el árbol. El proceso minimiza el SQL manual.
Construyendo un Hub
Crea un hub (tipo Hub). El sistema genera el DDL:
CREATE TABLE repo_fi.product_demo_hub (
date_load date DEFAULT now() NOT NULL,
src_sys text DEFAULT ''::character varying NOT NULL,
hkey int8 GENERATED BY DEFAULT AS IDENTITY
( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807
START 1 CACHE 20 NO CYCLE) NOT NULL,
CONSTRAINT product_demo_hub_pkey PRIMARY KEY (hkey)
)
USING heap
DISTRIBUTED REPLICATED;
COMMENT ON TABLE repo_fi.product_demo_hub IS '{ "app": "asapBI",
"descr": "Product Demo hub",
"type": "HUB",
"folder": "161"
}';
En el editor, activa los campos de servicio (casilla de verificación). Botones: agregar business key, satellite, link.
Agrega el campo product text con restricción UNIQUE y satellite:
ALTER TABLE repo_fi.product_demo_hub DROP CONSTRAINT product_demo_hub_unique;
ALTER TABLE repo_fi.product_demo_hub ADD product text;
COMMENT ON COLUMN repo_fi.product_demo_hub.product IS 'Produkt';
ALTER TABLE repo_fi.product_demo_hub ADD CONSTRAINT
product_demo_hub_unique UNIQUE ( product );
CREATE TABLE repo_fi.product_demo_hub_sat1 (
id bigint GENERATED BY DEFAULT AS IDENTITY primary key,
hkey bigint NOT NULL,
valid_from date DEFAULT now() NOT NULL,
date_load date DEFAULT now() NOT NULL,
src_sys text DEFAULT ''::character varying NOT NULL,
brand text,
categ text,
FOREIGN KEY (hkey) REFERENCES repo_fi.product_demo_hub (hkey)
)
USING heap
DISTRIBUTED REPLICATED;
COMMENT ON TABLE repo_fi.product_demo_hub_sat1 IS '{ "app": "asapBI",
"descr": "New sat",
"type": "SAT",
"owner": "repo_fi.product_demo_hub"
}';
ALTER TABLE repo_fi.product_demo_hub_sat1 ADD CONSTRAINT
product_demo_hub_sat1_unique UNIQUE (hkey, valid_from);
Hub de Customer y Link
De manera similar, crea el hub customer_demo_hub con el campo customer text:
CREATE TABLE repo_fi.customer_demo_hub (
date_load date DEFAULT now() NOT NULL,
src_sys text DEFAULT ''::character varying NOT NULL,
hkey int8 GENERATED BY DEFAULT AS IDENTITY
( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807
START 1 CACHE 20 NO CYCLE) NOT NULL,
customer text NULL,
CONSTRAINT customer_demo_hub_pkey PRIMARY KEY (hkey),
CONSTRAINT customer_demo_hub_unique UNIQUE (customer)
)
USING heap
DISTRIBUTED REPLICATED;
COMMENT ON TABLE repo_fi.customer_demo_hub IS '{ "app": "asapBI",
"descr": "Customer Demo hub",
"type": "HUB",
"folder": "161"
}';
Agrega un link entre los hubs:
CREATE TABLE repo_fi.customer_demo_hub_link1 (
id bigint GENERATED BY DEFAULT AS IDENTITY primary key,
customer_demo_hub bigint,
date_load date DEFAULT now() NOT NULL,
src_sys text DEFAULT ''::character varying NOT NULL,
product_demo_hub bigint ,
FOREIGN KEY (customer_demo_hub) REFERENCES repo_fi.customer_demo_hub (hkey),
FOREIGN KEY (product_demo_hub) REFERENCES repo_fi.product_demo_hub (hkey)
)
USING heap
DISTRIBUTED REPLICATED;
COMMENT ON TABLE repo_fi.customer_demo_hub_link1 IS '{ "app": "asapBI",
"descr": "New link",
"type": "LINK"
}';
ALTER TABLE repo_fi.customer_demo_hub_link1
ADD CONSTRAINT customer_demo_hub_link1_unique
UNIQUE (customer_demo_hub, product_demo_hub);
El link aparece debajo de ambos hubs. Se pueden agregar satellites a los links (+Sat).
Estructura DEMO:
- Hub de producto + satellite (brand, categ)
- Hub de customer
- Link entre hubs
Beneficios del Enfoque
- Generación automática de DDL: SQL completo para hubs, links, satellites con FK, UNIQUE y COMMENT JSON.
- Visualización: Árbol de objetos, diagramas de relaciones.
- Compatibilidad: El SQL se puede ejecutar manualmente (DBeaver), los objetos están sincronizados.
- Flexibilidad: Objetos temporales/permanentes, paquetes para CI/CD.
- Enfoque: Ocultar campos de servicio (hkey, date_load, src_sys).
Soporte para Greenplum; posible extensión a otros DBMS.
Puntos Clave
- Automatiza JOINs rutinarios y DDL en Data Vault.
- Integración con VSCode/Theia para desarrolladores intermedios/senior.
- Genera SQL listo para producción con metadatos en COMMENT.
- Soporte para links con FK a hkeys de hubs.
- Edición visual sin perder control del código.
— Editorial Team
Aún no hay comentarios.