NAME

dw-sample - generate a sample dataset

SYNOPSIS

# generate a sample.txt file containing 10,000 lines of random data
dw-sample --lines=10000 > sample.txt

DESCRIPTION

This script will generate a sample dataset for a sample database, that can be used for testing purposes.

Right now, this is our (very simple) sample star schema:

sqlite3 universe.db <<"SQL"
CREATE TABLE space_travel (
    id              INTEGER PRIMARY KEY,
    planet          INTEGER,
    constellation   INTEGER,
    star            INTEGER,
    value           FLOAT,
    n               INTEGER DEFAULT 1
);

CREATE TABLE planet (
    id      INTEGER PRIMARY KEY,
    name    VARCHAR(50)
);

CREATE TABLE constellation (
    id      INTEGER PRIMARY KEY,
    name    VARCHAR(50)
);

CREATE TABLE star (
    id      INTEGER PRIMARY KEY,
    name    VARCHAR(50)
);
SQL

This dataset is very crude and meaningless; I just copied some information from Acme::MetaSyntactic modules. Ideally we would populate planets, constellations and stars with more interesting information. Please let me know if you have any ideas on how to improve this.

Anyway, this dataset is enough to demonstrate the concepts behind the Perl Data Warehouse Toolkit.

# generate the sample data
dw-sample --lines=100000 > universe.txt

# generate the load script called "my-load-script.pl"
dw-load \
    --dsn='dbi:SQLite:dbname=universe.db' \
    --fact='space_travel' \
    --dimension='planet' \
    --dimension='constellation' \
    --dimension='star' \
        > my-load-script.pl

# the load script is not perfect yet; you'll have to change
# a few lines of code there before you proceed to the next
# step

# run the load script
perl my-load-script.pl < universe.txt

# Now you have a populated "universe.db" database!
# The load script took care of indexes, slowly changing
# dimensions, etc

# Now it is time to generate your data warehouse navigator,
# which is a simple web frontend to your data warehouse
dw-nav \
    --dsn='dbi:SQLite:dbname=universe.db' \
    --fact='space_travel' \
    --dimension='planet' \
    --dimension='constellation' \
    --dimension='star' \
        > my-dw-navigator.pl

# That's it!

# Start your server and connect to localhost:3000 to see
# your data warehouse in action:
perl my-dw-navigator.pl daemon

AUTHOR

Nelson Ferraz