Skip to content

Commit afcfd2d

Browse files
author
Josiah Baker
committed
port over to sql for data science
1 parent 4189842 commit afcfd2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+759785
-221
lines changed

README.md

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,21 @@
11
# AdventureWorks for Postgres
22

3-
This project provides the scripts necessary to set up the OLTP part of the go-to database used in
4-
training classes and for sample apps on the Microsoft stack. The result is 68 tables containing HR,
5-
sales, product, and purchasing data organized across 5 schemas. It represents a fictitious bicycle
6-
parts wholesaler with a hierarchy of nearly 300 employees, 500 products, 20000 customers, and 31000
7-
sales each having an average of 4 line items. So it's big enough to be interesting, but not
8-
unwieldy. In addition to being a well-rounded OLTP sample, it is also a good choice to demonstrate
9-
ETL into a data warehouse.
3+
This is based off the work done by [lorint](https://github.com/lorint/AdventureWorks-for-Postgres). We've already done the work to convert the csv's to be compatible with postgres. If you would like the original files, head over to [Adventure Works 2014 OLTP](https://msftdbprodsamples.codeplex.com/downloads/get/880662) download page. The download includes a script for loading the data into MSSQL Server.
104

11-
Provided is a ruby file to convert CSVs available on CodePlex into a format usable by Postgres, as
12-
well as a Postgres script to create the tables, load the data, convert the hierarchyid columns, add
13-
primary and foreign keys, and create some of the views used by Adventureworks.
5+
## Getting started
146

15-
## How to set up the database:
7+
First, make sure you have postgres installed. You can do this by typing `psql` in terminal.
8+
If nothing comes up, install postgres using `brew install postgres`. This will install and initialize a postgres database.
169

17-
Download [Adventure Works 2014 OLTP Script](https://msftdbprodsamples.codeplex.com/downloads/get/880662).
18-
(If this link becomes broken then here's the [original page](https://msftdbprodsamples.codeplex.com/releases/view/125550).)
10+
### Windows
1911

20-
Extract the .zip and copy all of the CSV files into the same folder, also containing update_csvs.rb file and install.sql.
12+
Head over to [https://www.postgresql.org/download/windows/](https://www.postgresql.org/download/windows/) and follow the instructions.
2113

22-
Modify the CSVs to work with Postgres by running:
23-
```
24-
ruby update_csvs.rb
25-
```
26-
Create the database and tables, import the data, and set up the views and keys with:
27-
```
28-
psql -c "CREATE DATABASE \"Adventureworks\";"
29-
psql -d Adventureworks < install.sql
30-
```
31-
All 68 tables are properly set up, and 11 of the 20 views are established. The ones not built are those that rely on XML functions like value and ref. To see a list of tables, open psql, and then connect to the database and show all the tables with these two commands:
32-
```
33-
\c "Adventureworks"
34-
\dt (humanresources|person|production|purchasing|sales).*
35-
```
14+
### Run the script
3615

37-
## Motivation
16+
Once you have confirmed your postgres install, run the following two lines:
3817

39-
Five years ago I was pretty happy developing .NET apps for large organizations. The stack was
40-
mature, and good practices surrounding software development were very respected. The same kind of
41-
approach I appreciated from my days writing Java code was there, and the community was passionate.
18+
psql -c "CREATE DATABASE \"Adventureworks\";"
19+
psql -d Adventureworks < install.sql
4220

43-
Then along came Windows 8. The //build/ conference in September 2011 revealed its first beta, and
44-
even with that early peek at the new direction things were headed, it was clear that everything about
45-
the platform was a haphazard combination of the new Metro apps along with all the traditional control
46-
panel and options and API for classic code. It left a very bad taste in my mouth. Perhaps it would
47-
look pretty, but be very unusable. I couldn't see it ever being successful. Once the "red pill"
48-
registry setting vanished from the builds in mid-2012, the Windows 7 interface was then no longer
49-
available even in Server editions. I knew it was time for a change. For a year I stuck it out
50-
watching to see if there was any hope for some kind of tablet miracle out of Redmond, but I was
51-
consistently unimpressed.
52-
53-
In mid-2013 a friend looped me in on a new project involving Ruby on Rails, and I fervently dove in
54-
and have very much enjoyed the elegance of that ecosystem. A big part of that has been ramping up my
55-
knowledge of Postgres. What a great database engine! I figure that others departing the Microsoft
56-
camp may appreciate the same data samples they're familiar with, so I created this along with the
57-
Northwind sample. It's been useful in the classroom training folks about Rails. I expect with the
58-
heavy-handed tactics Microsoft has now used around Windows 10 that even more organizations will
59-
choose to transition away from that platform, so there will be lots of opportunity for samples like
60-
this to help people learn a new environment.
61-
62-
As well, with the imminent release of SQL Server 2017 for Linux, this sample could be used to
63-
evaluate performance differences between Postgres and SQL 2017. Never thought I'd see the day that
64-
MS SQL got compiled for Linux, but alas, here we are.
65-
66-
Let's keep coding fun.
67-
68-
Enjoy!
21+
You're all set!

data/AWBuildVersion.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 12.0.1800 2014-02-20 04:26:00 2014-07-08 00:00:00

0 commit comments

Comments
 (0)