Commit 09b90ef1 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci

database: Replanning the database and its data marts 15

Signed-off-by: default avatarErik Alexandre Pucci <>
parent 10dfe99c
......@@ -126,6 +126,9 @@ comment on table dim_machine is 'Dimension table with machines inventory';
-- Fact tables
-- Nowadays, the availability table also represents the inventory received by
-- the web service server
-- Fact table with the history of machines connections
create table fact_availability (
contact_date date references dim_date,
......@@ -19,24 +19,7 @@
* USA.
/*create table sa_inventory (
project mec_project default 'proinfo' not null
contact_date date not null,
inep varchar(10) not null, -- Longest INEP has 10 characters
machine macaddr not null,
hd_model varchar(70) not null, -- Longest HD model has 47 characters
hd_size integer not null,
hd_used integer not null,
hd2_model varchar(70),
hd2_size integer,
hd2_used integer,
extra_hds integer default 0 not null,
memory_size integer not null,
processor varchar(70) not null, -- Longest processor model has 46 chars
os_type varchar(7) not null, -- 'Linux' or 'Windows'
os_distro varchar(50) not null, -- Longest OS distro has 35 characters
kernel varchar(40) not null, -- Longest kernel version has 24 chars
/* Needs fixes and tests! */
create or replace function load_data_warehouse() returns void as $$
......@@ -48,7 +31,8 @@ begin
-- Insert new contact dates into dim_date table
insert into dim_date select distinct contact_date from sa_inventory;
-- Insert new hardware components into theirs respective dimension tables
-- Insert new hardware and software components into their respective
-- dimension tables
insert into dim_os select distinct os_type, os_distro from sa_inventory;
insert into dim_kernel select distinct kernel from sa_inventory;
insert into dim_processor select distinct processor from sa_inventory;
......@@ -56,7 +40,8 @@ begin
insert into dim_hd select distinct hd_model, hd_size, hd_used, hd2_model,
hd2_size, hd2_used, extra_hds from sa_inventory;
/*insert into dim_machine (
-- Insert the new machines into dim_machine table
insert into dim_machine /*(
......@@ -65,19 +50,24 @@ begin
) select
)*/ select
(select id from dim_os t where os_type = t.os_type and os_distro =
t.os_distro) as os_id,
(select id from where) as kernel_id,
(select id from where) as processor_id,
(select id from where) as memory_id,
(select id from where) as hd_id,
(select id from dim_kernel t where kernel = t.kernel) as kernel_id,
(select id from dim_processor t where processor = t.processor) as processor_id,
(select id from dim_memory t where memory_size = t.memory_size) as memory_id,
(select id from dim_hd t where
hd_model = t.hd_model, hd_size = t.hd_size, hd_used = t.hd_used,
hd2_model = t.hd2_model, hd2_size = t.hd2_size,
hd2_used = t.hd2_used, extra_hds = t.extra_hds) as hd_id,
-- Update old machines whose components have changed, creating the alerts
/*update dim_machine set ...*/
-- Walk through every row in the staging area and update the data warehouse
-- tables accordingly
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