## create database postgres=>create database sample postgres=> \c sample ## it will prompt you to enter Postgres login password ## create schemas sample=>create schema landing; sample=>create schema dim; sample=>create schema fact; ## createtables sample=>createtable landing.rawdata ( name varchar(100) ,gender varchar(20) ,profession varchar(50) ,state varchar(2) ,asofdate date ,temperature float ,pulse int ); ## Import CSV data into Postgres table sample=> \COPY landing.rawdata FROM'/yourpath/sampleData.csv' DELIMITER ',' CSV HEADER; ## Add a surrogate ID column (surrogate column means, columnwith sequence of numbers, generally auto generated). sample=>altertable landing.rawdata add id serial; ## create dimension tables ## Fisrt Query createtable dim.gender as select row_number() Over(orderby gender) as genderid ,gender from (selectdistinct gender from landing.rawdata) t; ## Second Query createtable dim.person as select row_number() Over(orderby name) as personid ,name from (selectdistinct name from landing.rawdata) t; ## Third Query createtable dim.profession as select row_number() Over(orderby profession) as professionid ,profession from (selectdistinct profession from landing.rawdata) t; ## Fourth Query createtable dim.state as select row_number() Over(orderby state) as stateid ,state from (selectdistinct state from landing.rawdata) t; ## Build Fact table based on IDs from Dimension Table. createtable fact.user as select r.id ,p.personid ,g.genderid ,pr.professionID ,s.stateID ,r.asofdate ,r.temperature ,r.pulse from landing.rawdata r JOIN dim.person as p on r.name = p.name JOIN dim.gender as g on r.gender = g.gender JOIN dim.profession as pr on r.profession = pr.profession JOIN dim.state as s on r.state = s.state;