Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export PGUSER=postgres
psql <<- SHELL
CREATE USER docker;
CREATE DATABASE "AdventureWorks";
GRANT ALL PRIVILEGES ON DATABASE "AdventureWorks" TO docker;
CREATE DATABASE "Adventureworks";
GRANT ALL PRIVILEGES ON DATABASE "Adventureworks" TO docker;
SHELL
psql -d AdventureWorks < /data/install.sql
psql -d Adventureworks < /data/install.sql
78 changes: 39 additions & 39 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,31 @@ CREATE SCHEMA Person
COMMENT ON SCHEMA Person IS 'Contains objects related to names and addresses of customers, vendors, and employees';

SELECT 'Copying data into Person.BusinessEntity';
\copy Person.BusinessEntity FROM './BusinessEntity.csv' DELIMITER E'\t' CSV;
\copy Person.BusinessEntity FROM '/data/BusinessEntity.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.Person';
\copy Person.Person FROM './Person.csv' DELIMITER E'\t' CSV;
\copy Person.Person FROM '/data/Person.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.StateProvince';
\copy Person.StateProvince FROM './StateProvince.csv' DELIMITER E'\t' CSV;
\copy Person.StateProvince FROM '/data/StateProvince.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.Address';
\copy Person.Address FROM './Address.csv' DELIMITER E'\t' CSV ENCODING 'latin1';
\copy Person.Address FROM '/data/Address.csv' DELIMITER E'\t' CSV ENCODING 'latin1';
SELECT 'Copying data into Person.AddressType';
\copy Person.AddressType FROM './AddressType.csv' DELIMITER E'\t' CSV;
\copy Person.AddressType FROM '/data/AddressType.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.BusinessEntityAddress';
\copy Person.BusinessEntityAddress FROM './BusinessEntityAddress.csv' DELIMITER E'\t' CSV;
\copy Person.BusinessEntityAddress FROM '/data/BusinessEntityAddress.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.ContactType';
\copy Person.ContactType FROM './ContactType.csv' DELIMITER E'\t' CSV;
\copy Person.ContactType FROM '/data/ContactType.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.BusinessEntityContact';
\copy Person.BusinessEntityContact FROM './BusinessEntityContact.csv' DELIMITER E'\t' CSV;
\copy Person.BusinessEntityContact FROM '/data/BusinessEntityContact.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.EmailAddress';
\copy Person.EmailAddress FROM './EmailAddress.csv' DELIMITER E'\t' CSV;
\copy Person.EmailAddress FROM '/data/EmailAddress.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.Password';
\copy Person.Password FROM './Password.csv' DELIMITER E'\t' CSV;
\copy Person.Password FROM '/data/Password.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.PhoneNumberType';
\copy Person.PhoneNumberType FROM './PhoneNumberType.csv' DELIMITER E'\t' CSV;
\copy Person.PhoneNumberType FROM '/data/PhoneNumberType.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.PersonPhone';
\copy Person.PersonPhone FROM './PersonPhone.csv' DELIMITER E'\t' CSV;
\copy Person.PersonPhone FROM '/data/PersonPhone.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into Person.CountryRegion';
\copy Person.CountryRegion FROM './CountryRegion.csv' DELIMITER E'\t' CSV;
\copy Person.CountryRegion FROM '/data/CountryRegion.csv' DELIMITER E'\t' CSV;


CREATE SCHEMA HumanResources
Expand All @@ -212,7 +212,7 @@ CREATE SCHEMA HumanResources
CREATE TABLE Employee(
BusinessEntityID INT NOT NULL,
NationalIDNumber varchar(15) NOT NULL,
LoginID varchar(256) NOT NULL,
LoginID varchar(256) NOT NULL,
Org varchar NULL,-- hierarchyid, will become OrganizationNode
OrganizationLevel INT NULL, -- AS OrganizationNode.GetLevel(),
JobTitle varchar(50) NOT NULL,
Expand Down Expand Up @@ -268,17 +268,17 @@ CREATE SCHEMA HumanResources
COMMENT ON SCHEMA HumanResources IS 'Contains objects related to employees and departments.';

SELECT 'Copying data into HumanResources.Department';
\copy HumanResources.Department FROM './Department.csv' DELIMITER E'\t' CSV;
\copy HumanResources.Department FROM '/data/Department.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into HumanResources.Employee';
\copy HumanResources.Employee FROM './Employee.csv' DELIMITER E'\t' CSV;
\copy HumanResources.Employee FROM '/data/Employee.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into HumanResources.EmployeeDepartmentHistory';
\copy HumanResources.EmployeeDepartmentHistory FROM './EmployeeDepartmentHistory.csv' DELIMITER E'\t' CSV;
\copy HumanResources.EmployeeDepartmentHistory FROM '/data/EmployeeDepartmentHistory.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into HumanResources.EmployeePayHistory';
\copy HumanResources.EmployeePayHistory FROM './EmployeePayHistory.csv' DELIMITER E'\t' CSV;
\copy HumanResources.EmployeePayHistory FROM '/data/EmployeePayHistory.csv' DELIMITER E'\t' CSV;
SELECT 'Copying data into HumanResources.JobCandidate';
\copy HumanResources.JobCandidate FROM './JobCandidate.csv' DELIMITER E'\t' CSV ENCODING 'latin1';
\copy HumanResources.JobCandidate FROM '/data/JobCandidate.csv' DELIMITER E'\t' CSV ENCODING 'latin1';
SELECT 'Copying data into HumanResources.Shift';
\copy HumanResources.Shift FROM './Shift.csv' DELIMITER E'\t' CSV;
\copy HumanResources.Shift FROM '/data/Shift.csv' DELIMITER E'\t' CSV;

-- Calculated column that needed to be there just for the CSV import
ALTER TABLE HumanResources.Employee DROP COLUMN OrganizationLevel;
Expand Down Expand Up @@ -326,7 +326,7 @@ BEGIN
IF FOUND THEN
got_none := false;
END IF;

-- 101 = 8-15
UPDATE HumanResources.Employee
SET organizationnode = organizationnode || (SUBSTRING(org, 4,3)::bit(3)::INTEGER + 8)::VARCHAR || CASE SUBSTRING(org, 7, 1) WHEN '0' THEN '.' ELSE '/' END,
Expand Down Expand Up @@ -501,7 +501,7 @@ CREATE SCHEMA Production
Quantity smallint NOT NULL CONSTRAINT "DF_ProductInventory_Quantity" DEFAULT (0),
rowguid uuid NOT NULL CONSTRAINT "DF_ProductInventory_rowguid" DEFAULT (uuid_generate_v1()), -- ROWGUIDCOL
ModifiedDate TIMESTAMP NOT NULL CONSTRAINT "DF_ProductInventory_ModifiedDate" DEFAULT (NOW()),
-- CONSTRAINT "CK_ProductInventory_Shelf" CHECK ((Shelf LIKE 'AZa-z]') OR (Shelf = 'N/A')),
-- CONSTRAINT "CK_ProductInventory_Shelf" CHECK ((Shelf LIKE 'AZa-z]') OR (Shelf = '/data/A')),
CONSTRAINT "CK_ProductInventory_Bin" CHECK (Bin BETWEEN 0 AND 100)
)
CREATE TABLE ProductListPriceHistory(
Expand Down Expand Up @@ -670,13 +670,13 @@ SELECT 'Copying data into Production.ProductProductPhoto';
-- so instead ...
INSERT INTO Production.ProductReview (ProductReviewID, ProductID, ReviewerName, ReviewDate, EmailAddress, Rating, Comments, ModifiedDate) VALUES
(1, 709, 'John Smith', '2013-09-18 00:00:00', '[email protected]', 5, 'I can''t believe I''m singing the praises of a pair of socks, but I just came back from a grueling
3-day ride and these socks really helped make the trip a blast. They''re lightweight yet really cushioned my feet all day.
3-day ride and these socks really helped make the trip a blast. They''re lightweight yet really cushioned my feet all day.
The reinforced toe is nearly bullet-proof and I didn''t experience any problems with rubbing or blisters like I have with
other brands. I know it sounds silly, but it''s always the little stuff (like comfortable feet) that makes or breaks a long trip.
I won''t go on another trip without them!', '2013-09-18 00:00:00'),

(2, 937, 'David', '2013-11-13 00:00:00', '[email protected]', 4, 'A little on the heavy side, but overall the entry/exit is easy in all conditions. I''ve used these pedals for
more than 3 years and I''ve never had a problem. Cleanup is easy. Mud and sand don''t get trapped. I would like
(2, 937, 'David', '2013-11-13 00:00:00', '[email protected]', 4, 'A little on the heavy side, but overall the entry/exit is easy in all conditions. I''ve used these pedals for
more than 3 years and I''ve never had a problem. Cleanup is easy. Mud and sand don''t get trapped. I would like
them even better if there was a weight reduction. Maybe in the next design. Still, I would recommend them to a friend.', '2013-11-13 00:00:00'),

(3, 937, 'Jill', '2013-11-15 00:00:00', '[email protected]', 2, 'Maybe it''s just because I''m new to mountain biking, but I had a terrible time getting use
Expand All @@ -685,26 +685,26 @@ ways I can adjust the pedals, or is it just a learning curve thing?', '2013-11-1

(4, 798, 'Laura Norman', '2013-11-15 00:00:00', '[email protected]', 5, 'The Road-550-W from Adventure Works Cycles is everything it''s advertised to be. Finally, a quality bike that
is actually built for a woman and provides control and comfort in one neat package. The top tube is shorter, the suspension is weight-tuned and there''s a much shorter reach to the brake
levers. All this adds up to a great mountain bike that is sure to accommodate any woman''s anatomy. In addition to getting the size right, the saddle is incredibly comfortable.
Attention to detail is apparent in every aspect from the frame finish to the careful design of each component. Each component is a solid performer without any fluff.
levers. All this adds up to a great mountain bike that is sure to accommodate any woman''s anatomy. In addition to getting the size right, the saddle is incredibly comfortable.
Attention to detail is apparent in every aspect from the frame finish to the careful design of each component. Each component is a solid performer without any fluff.
The designers clearly did their homework and thought about size, weight, and funtionality throughout. And at less than 19 pounds, the bike is manageable for even the most petite cyclist.

We had 5 riders take the bike out for a spin and really put it to the test. The results were consistent and very positive. Our testers loved the manuverability
We had 5 riders take the bike out for a spin and really put it to the test. The results were consistent and very positive. Our testers loved the manuverability
and control they had with the redesigned frame on the 550-W. A definite improvement over the 2012 design. Four out of five testers listed quick handling
and responsivness were the key elements they noticed. Technical climbing and on the flats, the bike just cruises through the rough. Tight corners and obstacles were handled effortlessly. The fifth tester was more impressed with the smooth ride. The heavy-duty shocks absorbed even the worst bumps and provided a soft ride on all but the
and responsivness were the key elements they noticed. Technical climbing and on the flats, the bike just cruises through the rough. Tight corners and obstacles were handled effortlessly. The fifth tester was more impressed with the smooth ride. The heavy-duty shocks absorbed even the worst bumps and provided a soft ride on all but the
nastiest trails and biggest drops. The shifting was rated superb and typical of what we''ve come to expect from Adventure Works Cycles. On descents, the bike handled flawlessly and tracked very well. The bike is well balanced front-to-rear and frame flex was minimal. In particular, the testers
noted that the brake system had a unique combination of power and modulation. While some brake setups can be overly touchy, these brakes had a good
amount of power, but also a good feel that allows you to apply as little or as much braking power as is needed. Second is their short break-in period. We found that they tend to break-in well before
the end of the first ride; while others take two to three rides (or more) to come to full power.
the end of the first ride; while others take two to three rides (or more) to come to full power.

On the negative side, the pedals were not quite up to our tester''s standards.
On the negative side, the pedals were not quite up to our tester''s standards.
Just for fun, we experimented with routine maintenance tasks. Overall we found most operations to be straight forward and easy to complete. The only exception was replacing the front wheel. The maintenance manual that comes
with the bike say to install the front wheel with the axle quick release or bolt, then compress the fork a few times before fastening and tightening the two quick-release mechanisms on the bottom of the dropouts. This is to seat the axle in the dropouts, and if you do not
do this, the axle will become seated after you tightened the two bottom quick releases, which will then become loose. It''s better to test the tightness carefully or you may notice that the two bottom quick releases have come loose enough to fall completely open. And that''s something you don''t want to experience
while out on the road!
while out on the road!

The Road-550-W frame is available in a variety of sizes and colors and has the same durable, high-quality aluminum that AWC is known for. At a MSRP of just under $1125.00, it''s comparable in price to its closest competitors and
we think that after a test drive you''l find the quality and performance above and beyond . You''ll have a grin on your face and be itching to get out on the road for more. While designed for serious road racing, the Road-550-W would be an excellent choice for just about any terrain and
we think that after a test drive you''l find the quality and performance above and beyond . You''ll have a grin on your face and be itching to get out on the road for more. While designed for serious road racing, the Road-550-W would be an excellent choice for just about any terrain and
any level of experience. It''s a huge step in the right direction for female cyclists and well worth your consideration and hard-earned money.', '2013-11-15 00:00:00');

SELECT 'Copying data into Production.ScrapReason';
Expand Down Expand Up @@ -767,7 +767,7 @@ BEGIN
IF FOUND THEN
got_none := false;
END IF;

-- 101 = 8-15
UPDATE Production.Document
SET DocumentNode = DocumentNode || (SUBSTRING(doc, 4,3)::bit(3)::INTEGER + 8)::VARCHAR || CASE SUBSTRING(doc, 7, 1) WHEN '0' THEN '.' ELSE '/' END,
Expand Down Expand Up @@ -848,7 +848,7 @@ BEGIN
IF FOUND THEN
got_none := false;
END IF;

-- 101 = 8-15
UPDATE Production.ProductDocument
SET DocumentNode = DocumentNode || (SUBSTRING(doc, 4,3)::bit(3)::INTEGER + 8)::VARCHAR || CASE SUBSTRING(doc, 7, 1) WHEN '0' THEN '.' ELSE '/' END,
Expand Down Expand Up @@ -1010,7 +1010,7 @@ CREATE SCHEMA Sales
)
CREATE TABLE CurrencyRate(
CurrencyRateID SERIAL NOT NULL, -- int
CurrencyRateDate TIMESTAMP NOT NULL,
CurrencyRateDate TIMESTAMP NOT NULL,
FromCurrencyCode char(3) NOT NULL,
ToCurrencyCode char(3) NOT NULL,
AverageRate numeric NOT NULL, -- money
Expand Down Expand Up @@ -1066,7 +1066,7 @@ CREATE SCHEMA Sales
ShipToAddressID INT NOT NULL,
ShipMethodID INT NOT NULL,
CreditCardID INT NULL,
CreditCardApprovalCode varchar(15) NULL,
CreditCardApprovalCode varchar(15) NULL,
CurrencyRateID INT NULL,
SubTotal numeric NOT NULL CONSTRAINT "DF_SalesOrderHeader_SubTotal" DEFAULT (0.00), -- money
TaxAmt numeric NOT NULL CONSTRAINT "DF_SalesOrderHeader_TaxAmt" DEFAULT (0.00), -- money
Expand Down Expand Up @@ -2567,7 +2567,7 @@ SELECT
,p.MiddleName
,p.LastName
,p.Suffix
,e.JobTitle
,e.JobTitle
,pp.PhoneNumber
,pnt.Name AS PhoneNumberType
,ea.EmailAddress
Expand Down Expand Up @@ -2830,7 +2830,7 @@ FROM (SELECT JobCandidateID
-- simpler thing for "ns" since this will only be used only in the xpath queries above.
,('<root xmlns:ns="http://adventureworks.com">' ||
unnesting.Education::varchar ||
'</root>')::xml AS doc
'/data/root>')::xml AS doc
FROM (SELECT JobCandidateID
,UNNEST(xpath('/ns:Resume/ns:Education', Resume, '{{ns,http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/Resume}}')) AS Education
FROM HumanResources.JobCandidate) AS unnesting) AS jc;
Expand Down