Create staging tables

In this section, we create a database, some schemas, and three tables to hold our staging data.

If you’d like to follow along, please see the resources below.

Resources

The Superstore dataset I work with is available here: https://docs.google.com/spreadsheets/d/1Uvk0HdRb-LAfy7MiMtianadO8a0KVxot/edit?gid=2015463787#gid=2015463787

The software I use (PostgreSQL and pgAdmin) is available here: https://www.postgresql.org/download/

SQL to create tables:

CREATE TABLE superstore.staging.orderitems
(
    rowid INT PRIMARY KEY
    ,orderid VARCHAR(50)
    ,orderdate VARCHAR(12)
    ,shipdate VARCHAR(12)
    ,shipmode VARCHAR(50) 
    ,customerid VARCHAR(25) 
    ,customername VARCHAR(50) 
    ,segment VARCHAR(50) 
    ,countryregion VARCHAR(25) 
    ,city VARCHAR(25) 
    ,stateprovince VARCHAR(25) 
    ,postalcode VARCHAR(10) 
    ,region VARCHAR(50) 
    ,productid VARCHAR(50)
    ,category VARCHAR(25)
    ,subcategory VARCHAR(25)
    ,productname VARCHAR(150)
    ,sales NUMERIC
    ,quantity INT
    ,discount NUMERIC
    ,profit NUMERIC
)
;

/* People staging table */
CREATE TABLE superstore.staging.people
(
    person VARCHAR(50)
    ,region VARCHAR(25)
)
;


/* Returns staging table */
CREATE TABLE IF NOT EXISTS staging.returns
(
    orderid VARCHAR(15)
)

;