Commit f1af2667 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci

database: Replanning the database and its data marts 44

Signed-off-by: default avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
parent b8343ed5
......@@ -19,14 +19,6 @@
* USA.
*/
/* Enum type for the class_enum of the machines according to their
* availability */
create type class_enum as enum (
'green', /* Communication ocurred at most 10 days ago */
'yellow', /* Communication ocurred between 10 and 30 days */
'red' /* Communication hasn't occured for more than 30 days */
);
/* -------------------------------------------------------------------------- */
/* Last load availability tables */
......
......@@ -19,14 +19,6 @@
* USA.
*/
/* Enum type for the components category */
create type category_enum as enum (
'os',
'kernel',
'processor',
'hd'
);
/* -------------------------------------------------------------------------- */
/* Dimension tables */
......@@ -59,13 +51,13 @@ create table dim_component (
description text not null, /* HD model, OS type, kernel and
* processor model */
detail text, /* HD size and OS distro */
unique(description, detail)
unique(category, description, detail)
);
/* This index is necessary to treat null values as equals, thus not accepting
* repeated processor models and kernel data, since they have no detail, neither
* accepting HDs without size */
create unique index dim_c_constraint on dim_component (description) where detail
is null;
create unique index dim_c_constraint on dim_component (category, description)
where detail is null;
/* Dimension table with machines inventory */
create table dim_machine (
......
......@@ -32,6 +32,7 @@ password=$3
createdb ${database}
psql -c "create role ${user} login;"
psql -c "alter role ${user} password '${password}';"
psql -d ${database} -f ${PREFIX}/create_types.sql
psql -d ${database} -f ${PREFIX}/create_staging_areas.sql
psql -d ${database} -f ${PREFIX}/create_data_warehouse.sql
psql -d ${database} -f ${PREFIX}/create_data_marts.sql
......
......@@ -19,20 +19,6 @@
* USA.
*/
/* Enum type for the MEC project which the machines belong to */
create type project_enum as enum (
'proinfo',
'uca_classmate',
'uca_server',
'projector'
);
/* Enum type for the OS type, which can be "linux" or "windows" */
create type os_type_enum as enum (
'linux',
'windows'
);
/* -------------------------------------------------------------------------- */
/* Staging area tables */
......
......@@ -255,16 +255,15 @@ begin
raise log 'Done'
no_data_hash = select md5(no_data_os::text || no_data_kernel::text ||
no_data_processor::text || no_data_hd::text || '0' || no_data_hd::text
|| '0' || '0');
no_data_processor::text || '0' || no_data_hd::text || '0' || '0');
raise log 'Inserting contact data from "mectb05_disponibilidade_fact" '
'data to "fact_inventory", using "no data" flag for the components...';
insert into fact_inventory (load_date, contact_date, machine_id, os_id,
kernel_id, processor_id, memory, hd_id, hd_used, hd2_id, hd2_used,
extra_hds, hash)
select load_date, *, no_data_os, no_data_kernel, no_data_processor,
no_data_hd, 0, no_data_hd, 0, 0, no_data_hash from (select dat_data,
select load_date, *, no_data_os, no_data_kernel, no_data_processor, 0,
no_data_hd, 0, null, null, 0, no_data_hash from (select dat_data,
dim_machine.id from mectb05_disponibilidade_fact,
mectb01_escola_dim, mectb03_data_dim, mectb04_maquina_dim,
dim_school, dim_machine where dis_dat_id = dat_id and dis_maq_id =
......@@ -276,12 +275,20 @@ begin
raise log 'Done';*/
/* Insert machines changes data into fact_alert */
select distinct on (machine_id, hash) contact_date, machine_id, hash from
fact_inventory order by contact_date, machine_id
select id, contact_date, machine_id, hash from
(select distinct on (i.machine_id, hash) contact_date, i.machine_id,
hash from fact_inventory i,
(select machine_id from (select distinct machine_id, hash from
fact_inventory) s group by machine_id having count(*) > 1) t where
i.machine_id = t.machine_id) u order by contact_date, machine_id;
raise log 'Inserting alert data from "fact_inventory" to "fact_alert"...';
insert into fact_alert (load_date, old_inventory, inventory, memory_alert,
hd_alert)
select load_date, first_value(id) over (partition by contact_date order
by contact_date), id, ..., ...
from
get diagnostics tmp = ROW_COUNT;
count := count + tmp;
raise log 'Done';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment