Commit 037e1965 authored by O'Reilly Media, Inc's avatar O'Reilly Media, Inc
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+5 −0
Changes for Learning Data Modeling - Working Files/Chapter 1/ContactInfo.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
Dr. Michael Blaha -- contact information

email -- blaha@computer.org

Web -- www.superdataguy.com
 No newline at end of file
+21.4 KiB

File added.

No diff preview for this file type.

+35 −0
Changes for Learning Data Modeling - Working Files/Chapter 10/0_loadSampleData.sql: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
-- Sample data for testing database for Tim's Sandwich Shop
-- It is tedious to specify data this way. Brute force SQL is OK for early testing. Production software should have data interfaces.

-- There's a single sandwich shop record -- Tim's sandwich shop.
INSERT INTO SandwichShop (sandwichShopName,  URL)
VALUES ('Tim''s Sandwich Shop', 'www.TimsSandwichShop.com');


-- Load data for a single menu.
INSERT INTO Menu (menuName)
VALUES ('Fall Menu');


-- Load data for one sandwich shop location,
INSERT INTO Address (addressData)
VALUES ('123 Main Street  Anywhere, Colorado  80905 USA');

INSERT INTO Location (phoneNumber, sandwichShopID, addressID, menuID)
SELECT '555-9876'
     , (SELECT sandwichShopID FROM SandwichShop WHERE sandwichShopName = 'Tim''s Sandwich Shop')
     , (SELECT addressID FROM Address WHERE addressData = '123 Main Street  Anywhere, Colorado  80905 USA')
     , (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for another sandwich shop location.
INSERT INTO Address (addressData)
VALUES ('456 State Street  Somewhere, New Mexico  87501 USA');

INSERT INTO Location (phoneNumber, sandwichShopID, addressID, menuID)
SELECT '555-2345'
     , (SELECT sandwichShopID FROM SandwichShop WHERE sandwichShopName = 'Tim''s Sandwich Shop')
     , (SELECT addressID FROM Address WHERE addressData = '456 State Street  Somewhere, New Mexico  87501 USA')
     , (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.
+95 −0
Changes for Learning Data Modeling - Working Files/Chapter 10/1_loadSampleData.sql: 95 added lines, 0 removed lines.
Original line number Diff line number Diff line
-- Sample data for testing database for Tim's Sandwich Shop
-- It is tedious to specify data this way. Brute force SQL is OK for early testing. Production software should have data interfaces.

-- Load data for small and large reuben sandwich
INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'sandwich', 'reuben sandwich', 'small', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'sandwich', 'reuben sandwich', 'large', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for small custom sandwich
INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'sandwich', 'custom sandwich', 'small', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for small custom sandwich, bread
INSERT INTO ItemIngredient (itemIngredientName, menuItemID)
SELECT 'bread', (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'custom sandwich' AND menuItemSize = 'small')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'white', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'bread')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'wheat', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'bread')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'rye', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'bread')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for small custom sandwich, cheese
INSERT INTO ItemIngredient (itemIngredientName, menuItemID)
SELECT 'cheese', (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'custom sandwich' AND menuItemSize = 'small')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'swiss', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'cheese')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'cheddar', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'cheese')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for small custom sandwich, meat
INSERT INTO ItemIngredient (itemIngredientName, menuItemID)
SELECT 'meat', (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'custom sandwich' AND menuItemSize = 'small')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'chicken', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'meat')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'roast beef', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'meat')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO IngredientChoice (ingredientChoiceName, itemIngredientID)
SELECT 'ham', (SELECT itemIngredientID FROM ItemIngredient II INNER JOIN MenuItem MI ON II.menuItemID = MI.menuItemID
                 WHERE MI.menuItemName = 'custom sandwich' and MI.menuItemSize = 'small' and II.itemIngredientName = 'meat')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for beverage
INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'beverage', 'coffee', 'small', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'beverage', 'tea', 'small', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Load data for salad
INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'salad', 'garden salad', 'medium', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO MenuItem (menuItemType, menuItemName, menuItemSize, menuID)
SELECT 'salad', 'chicken Caesars salad', 'medium', (SELECT menuID FROM Menu WHERE menuName = 'Fall Menu')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.
+108 −0
Changes for Learning Data Modeling - Working Files/Chapter 10/2_loadSampleData.sql: 108 added lines, 0 removed lines.
Original line number Diff line number Diff line
-- Sample data for testing database for Tim's Sandwich Shop
-- It is tedious to specify data this way. Brute force SQL is OK for early testing. Production software should have data interfaces.

INSERT INTO Discount (discountName) VALUES ('none');
INSERT INTO Discount (discountName) VALUES ('senior');


-- Reuben sandwich, discount none
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 3.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'reuben sandwich' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 5.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'reuben sandwich' AND menuItemSize = 'large')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Reuben sandwich, discount senior
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 2.85
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'reuben sandwich' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 4.75
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'reuben sandwich' AND menuItemSize = 'large')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Custom sandwich
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 3.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'custom sandwich' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 2.85
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'custom sandwich' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Coffee
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 1.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'coffee' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 1.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'coffee' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Tea
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 1.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'tea' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 1.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'tea' AND menuItemSize = 'small')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Salad, discount none
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 4.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'garden salad' AND menuItemSize = 'medium')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 4.00
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'chicken Caesars salad' AND menuItemSize = 'medium')
     , (SELECT discountID FROM Discount WHERE discountName = 'none')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


-- Salad, discount senior
INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 3.80
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'garden salad' AND menuItemSize = 'medium')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.

INSERT INTO ListPrice (listPriceAmount, menuItemID, discountID)
SELECT 3.80
     , (SELECT menuItemID FROM MenuItem WHERE menuItemName = 'chicken Caesars salad' AND menuItemSize = 'medium')
     , (SELECT discountID FROM Discount WHERE discountName = 'senior')
FROM SandwichShop;     -- The table name here is just a placeholder to satisfy SQL syntax.


INSERT INTO DeliveryType (deliveryTypeName) VALUES ('at table');
INSERT INTO DeliveryType (deliveryTypeName) VALUES ('at address');
Loading