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

database: Replanning the database and its data marts 12

Signed-off-by: default avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
parent 84690b3d
Steps of Creating the Database
==============================
1) Type
./create/create_bd.sh
Steps of Loading
1) Type
./load/c_load.sh
2) Type
./cron.sh
......@@ -2,8 +2,15 @@
# PROINFODATA DATABASE
#######################################################################
To create the database, read "CREATE".
To load the database, read "LOADING".
To new features and other news, read "NEWS".
To credits, read "AUTHORS".
To copyright information, read "COPYING".
To create the database, execute:
./create/create_database.sh <user> <password>
To load the database, execute:
./load/c_load.sh
./config_crontab.sh
For credits, read "AUTHORS".
For copyright information, read "COPYING".
/* Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of database
*
* database is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
COMMENT ON TABLE mectb00_staging_area IS 'Transition table with temporary
data';
COMMENT ON TABLE mectb01_escola_dim IS 'Table with data from schools.';
COMMENT ON TABLE mectb02_catalogo_dim IS 'Catalog table of hardware
components.';
COMMENT ON TABLE mectb03_data_dim IS 'Table of dates.';
COMMENT ON TABLE mectb04_maquina_dim IS 'Table with data from machines.';
COMMENT ON TABLE mectb05_disponibilidade_fact IS 'Table with history of
machines connections.';
COMMENT ON TABLE mectb06_uso_fact IS 'Table using the network of machines.';
COMMENT ON TABLE mectb07_inventario_fact IS 'Inventory table of the
machines.';
COMMENT ON TABLE mectb08_dm_disp IS 'Classification table of the
availability of machines.';
COMMENT ON TABLE mectb09_dm_disp_ag IS 'Aggregation by city table
mectb08_dm_disp.';
COMMENT ON TABLE mectb10_dm_inventario IS 'Join table of inventory from
machines.';
COMMENT ON TABLE mectb11_dm_auditoria IS 'Table grouping by the School of
machines installed and expected.';
COMMENT ON TABLE mectb12_dm_instaladas_ag IS 'Table grouping by month and
state of the machines installed, provided, by changing the hard disk and
memory.';
COMMENT ON TABLE mectb13_dm_rede IS 'Table that stores per-school network
usage information.';
/* Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of database
*
* database is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
comment on table sa_inventory is 'Transition table with temporary machines
inventory data';
comment on table sa_net_usage is 'Transition table with temporary network usage
data';
--------------------------------------------------------------------------------
comment on table dim_data is 'Dimension table of dates';
comment on table dim_time is 'Dimension table with collect times during a day';
comment on table dim_school is 'Dimension table with data about the schools';
comment on table dim_catalog is 'Dimension table of hardware components';
comment on table dim_machine is 'Dimension table with machines inventory';
comment on table dim_net_usage is 'Dimension table with machines network usage';
--------------------------------------------------------------------------------
comment on table fact_availability is 'Fact table with the history of machines
connections';
comment on table fact_alert is 'Fact table with the history of machines
modifications';
comment on table fact_net_usage_school is 'Fact table with the history of
network usage per school';
--------------------------------------------------------------------------------
comment on table dm_avail_state is 'Data mart table of availability per state';
comment on table dm_avail_city is 'Data mart table of availability per city';
comment on table dm_avail_school is 'Data mart table of availability per
school';
comment on table dm_avail_machine is 'Data mart table with availability per
machine';
comment on table dm_avail_state_history is 'Data mart table with the history of
availability per state and month';
comment on table dm_avail_city_history is 'Data mart table with the history of
availability per city and month';
comment on table dm_invent_machine is 'Data mart table with the machines
inventory';
comment on table dm_audit_zm_school is 'Data mart table with schools without any
machine communicating';
comment on table dm_alert_state is 'Data mart table with alerts per state';
comment on table dm_alert_city is 'Data mart table with alerts per city';
comment on table dm_alert_school is 'Data mart table with alerts per school';
comment on table dm_alert_machine is 'Data mart table with machines alerts';
comment on table dm_alert_state_history is 'Data mart table with the history of
alerts per state and month';
comment on table dm_alert_city_history is 'Data mart table with the history of
alerts per city and month';
comment on table dm_net_usage_state is 'Data mart table with network usage per
state';
comment on table dm_net_usage_city is 'Data mart table with network usage per
city';
comment on table dm_net_usage_school is 'Data mart table with network usage per
school';
......@@ -19,12 +19,17 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
psql -f create_sa.sql
psql -d proinfodata -f create_control.sql
psql -d proinfodata -f create_dm.sql
psql -d proinfodata -f create_dw.sql
psql -d proinfodata -f comment_table.sql
psql -d proinfodata -f create_user.sql
if test $# -ne 2; then
printf "Usage: ./create_database.sh <user> <password>"
exit 1
fi
psql -c "create database proinfodata;"
psql -c "create role ${user} login;"
psql -c "alter role ${user} password '${password}';"
psql -d proinfodata -f create_staging_areas.sql
psql -d proinfodata -f create_datawarehouse.sql
psql -d proinfodata -f create_datamarts.sql
psql -d proinfodata -f create_indexes.sql
psql -d proinfodata -f comment_tables.sql
psql -d proinfodata -f grants_user.sql
psql -d proinfodata -f insert_datas_1.sql
psql -d proinfodata -f insert_datas_2.sql
......@@ -38,9 +38,6 @@ create table dm_avail_state (
green integer not null,
yellow integer not null,
red integer not null
--expected smallint -- Information that would come from MEC database, if
-- they had it, regarding the expected number of
-- machines
);
create table dm_avail_city (
......@@ -51,7 +48,6 @@ create table dm_avail_city (
green integer not null,
yellow integer not null,
red integer not null
--expected smallint
);
create table dm_avail_school (
......@@ -64,7 +60,6 @@ create table dm_avail_school (
green integer not null,
yellow integer not null,
red integer not null
--expected smallint
);
create table dm_avail_machine (
......@@ -93,7 +88,6 @@ create table dm_avail_state_history (
green integer not null,
yellow integer not null,
red integer not null
--expected smallint
);
create table dm_avail_city_history (
......@@ -105,7 +99,6 @@ create table dm_avail_city_history (
green integer not null,
yellow integer not null,
red integer not null
--expected smallint
);
--------------------------------------------------------------------------------
......@@ -123,7 +116,6 @@ create table dm_invent_machine (
processor varchar(70) not null,
memory_size integer not null,
hd_size integer not null
--hd_used varchar
);
--------------------------------------------------------------------------------
......@@ -147,8 +139,6 @@ create table dm_alert_state (
state varchar(2) not null,
memory_amount integer not null,
hd_amount integer not null
--total integer not null,
--both_amount integer -- If the others are exclusive
);
create table dm_alert_city (
......@@ -157,8 +147,6 @@ create table dm_alert_city (
city varchar(50) not null,
memory_amount integer not null,
hd_amount integer not null
--total integer not null,
--both_amount integer
);
create table dm_alert_school (
......@@ -169,8 +157,6 @@ create table dm_alert_school (
school varchar(100) not null,
memory_amount integer not null,
hd_amount integer not null
--total integer not null,
--both_amount integer
);
create table dm_alert_machine (
......@@ -202,8 +188,6 @@ create table dm_alert_state_history (
state varchar(2) not null,
memory_amount integer not null,
hd_amount integer not null
--total integer not null,
--both_amount integer not null
);
create table dm_alert_city_history (
......@@ -213,8 +197,6 @@ create table dm_alert_city_history (
city varchar(50) not null,
memory_amount integer not null,
hd_amount integer not null
--total integer not null,
--both_amount integer not null
);
--------------------------------------------------------------------------------
......
......@@ -48,7 +48,6 @@ create table dim_school (
school varchar(100) not null, -- MEC web service limit for school names
code varchar(8),
address varchar(100) -- Longest address has 70 characters
--expected smallint
);
create table dim_catalog (
......@@ -73,9 +72,18 @@ create table dim_machine (
hd_id integer references dim_catalog,
memory_id integer references dim_catalog
machine macaddr not null,
project mec_project default 'proinfo' not null,
--internet_con boolean default true not null,
unique (inep, machine)
project mec_project default 'proinfo' not null
);
create table dim_net_usage (
id serial primary key,
collect_date date references dim_date,
collect_time timestamp references dim_time,
machine_id integer references dim_machine
down_packages integer not null,
down_bytes bigint not null,
up_packages integer not null,
up_bytes bigint not null
);
--------------------------------------------------------------------------------
......@@ -87,14 +95,14 @@ create table fact_availability (
);
-- This is not even a "factless table", so will be kept in dim_machine
--create table fact_inventory (
-- machine_id integer references dim_machine,
-- os_id integer references dim_catalog,
-- kernel_id integer references dim_catalog,
-- processor_id integer references dim_catalog,
-- hd_id integer references dim_catalog,
-- memory_id integer references dim_catalog
--);
/*create table fact_inventory (
machine_id integer references dim_machine,
os_id integer references dim_catalog,
kernel_id integer references dim_catalog,
processor_id integer references dim_catalog,
hd_id integer references dim_catalog,
memory_id integer references dim_catalog
);*/
-- Just for alerts or for any changes about the machines?
create table fact_alert (
......@@ -107,13 +115,12 @@ create table fact_alert (
);
-- More work is needed on network dimension model
create table fact_net_usage (
collect_date date references dim_date,
collect_time timestamp references dim_time,
machine_id integer references dim_machine
--collect_time timestamp not null, -- Date and time dimension tables?
down_packages integer not null,
down_bytes bigint not null,
up_packages integer not null,
up_bytes bigint not null
create table fact_net_usage_school (
collect_date date references dim_date,
collect_time timestamp references dim_time,
inep varchar(12) references dim_school,
down_packages integer not null,
down_bytes bigint not null,
up_packages integer not null,
up_bytes bigint not null
);
......@@ -19,10 +19,6 @@
* USA.
*/
create database proinfodata;
\c proinfodata;
-- Enum type for the MEC project which the machines belong to
create type mec_project as enum (
'proinfo',
......@@ -51,7 +47,6 @@ create table sa_inventory (
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
--internet_con boolean default true not null,
);
create table sa_net_usage (
......
/* Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of database
*
* database is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
create role my_user login;
alter role my_user password 'password';
/* Copyright (C) 2009-2012 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of datebase
*
* datebase is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPosE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
-- This script must be used only when there is new data about the schools or
-- machines, or a change in the graphs or reports. This is a recall and an
-- indicatation to the changes that must be done. Don't forget to update the
-- load scripts and to really load the tables with the new data
--------------------------------------------------------------------------------
-- Information about the origin of the machine data: if it was from the Internet
-- (automatically sent by the agent), or by (e-)mail/in person
alter table sa_inventory add column internet_con boolean default true not null;
alter table dim_machine add column internet_con boolean default true not null;
--------------------------------------------------------------------------------
-- Information that would come from MEC database, if they had it, regarding the
-- expected number of machines
alter table dim_school add column expected smallint default 0 not null;
alter table dm_avail_state add column expected smallint default 0 not null;
alter table dm_avail_city add column expected smallint default 0 not null;
alter table dm_avail_school add column expected smallint default 0 not null;
alter table dm_avail_state_history add column expected smallint default 0 not
null;
alter table dm_avail_city_history add column expected smallint default 0 not
null;
--------------------------------------------------------------------------------
-- Information to the inventory report about the amount used of the first HD
alter table dm_invent_machine add column hd_used integer default 0 not null;
--------------------------------------------------------------------------------
-- Information to the inventory report about the other HDs
alter table dm_invent_machine add column hd2_size integer default 0 not null;
alter table dm_invent_machine add column hd2_used integer default 0 not null;
alter table dm_invent_machine add column extra_hds integer default 0 not null;
--------------------------------------------------------------------------------
-- Information to the inventory report about the HD models
alter table dm_invent_machine add column hd_model varchar(70) default 0 not
null;
alter table dm_invent_machine add column hd2_model varchar(70) default 0 not
null;
--------------------------------------------------------------------------------
-- Information to the alert report about the total of alerts
alter table dm_alert_state add column total integer default 0 not null;
alter table dm_alert_city add column total integer default 0 not null;
alter table dm_alert_school add column total integer default 0 not null;
alter table dm_alert_state_history add column total integer default 0 not null;
alter table dm_alert_city_history add column total integer default 0 not null;
--------------------------------------------------------------------------------
-- Information to the alert report about the machines
-- that have both alerts at the same time (if the others are exclusive)
alter table dm_alert_state add column both_amount integer default 0 not null;
alter table dm_alert_city add column both_amount integer default 0 not null;
alter table dm_alert_school add column both_amount integer default 0 not null;
alter table dm_alert_state_history add column both_amount integer default 0 not
null;
alter table dm_alert_city_history add column both_amount integer default 0 not
null;
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