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
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"editor.cursorBlinking": "solid",
"editor.fontFamily": "ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace",
"editor.fontLigatures": false,
"editor.fontSize": 22,
"editor.fontSize": 16,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.lineNumbers": "on",
Expand All @@ -17,8 +17,7 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true
}
}
19 changes: 17 additions & 2 deletions 01_restaurant/challenges/01_01_invitations_ch.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
-- Generate a list of customer information.
-- Generate a list -- yes a list!--of customer information.

-- Show their first name, last name, and email address.
-- Sort the list of results by last name.
-- Sort the list of results by last name.
SELECT
FirstName,
LastName,
Email

FROM
Customers

ORDER BY
LastName

CREATE TABLE AnniversaryPartyAttendess )
CustomerID INTEGER,
PartySize INTEGER
);
5 changes: 4 additions & 1 deletion 01_restaurant/challenges/01_02_anniversary_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
-- Associate a customer's ID number with the number of people
-- they plan to bring in their party.

-- Hint: SQLite offers the INTEGER and REAL datatypes
-- Hint: SQLite offers the INTEGER and REAL datatypes
CREATE TABLE AnniversaryParty (
CustomerID INTEGER,
Party INTEGER);
16 changes: 15 additions & 1 deletion 01_restaurant/challenges/01_03_printmenus_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@

-- Create a report with all the items sorted by price (lowest to highest).
-- Create a report showing appetizers and beverages.
-- Create a report with all items except beverages.
-- Create a report with all items except beverages.

/*Types: Appetizer, Main, Dessert, Beverage
*/

SELECT
Name,
Type,
Price
FROM
Dishes
WHERE
Type IN ('Appetizer', 'Beverage');
ORDER BY
Type;
16 changes: 15 additions & 1 deletion 01_restaurant/challenges/01_04_newcustomer_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@
-- Use the following information to create a record:
-- Anna Smith (asmith@samoca.org)
-- 479 Lapis Dr., Memphis, TN
-- Phone: (555) 555-1212; Birthday: July 21, 1973
-- Phone: (555) 555-1212; Birthday: July 21, 1973

INSERT INTO
Customers (FirstName, LastName, Email, Address, City, State, Phone, Birthday)
VALUES
('Anna', 'Smith', 'asmith@samoca.org', '479 Lapis Dr.', 'Memphis', 'TN', '(555) 555-1212',
'1973-07-21');

SELECT * FROM Customers ORDER BY CustomerID DESC;

DELETE
FROM
Customers
WHERE
CustomerID = 101;
23 changes: 22 additions & 1 deletion 01_restaurant/challenges/01_05_updateinfo_ch.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
-- Update a customer's contact information.

-- Taylor Jenkins, of 27170 6th Ave., Washington, DC,
-- has moved to 74 Pine St., New York, NY.
-- has moved to 74 Pine St., New York, NY.

SELECT
CustomerID,
FirstName,
LastName,
Address
FROM
Customers
WHERE
FirstName = 'Taylor'
AND
LastName = 'Jenkins';

UPDATE
Customers
SET
Address = '74 Pine St.', City = 'New York', State = 'NY'
WHERE
CustomerID = 26;

Select * FROM Customers WHERE CustomerID = 26;
49 changes: 48 additions & 1 deletion 01_restaurant/challenges/01_06_removeinfo_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,51 @@

-- A customer named Norby has notified us he won't
-- be able to keep his Friday reservation.
-- Today is July 24, 2022.
-- Today is July 24, 2022.

-- Find his customer ID,
-- locate the date, get Reservation ID
-- remove the for where Reserveration ID = blahblahblah

SELECT
LastName,
FirstName,
CustomerID
FROM
Customers
WHERE
LastName = 'Norby'
OR
FirstName = 'Norby';

SELECT
ReservationID,
Date(Date) as Day

FROM
Reservations
WHERE
CustomerID = 64
AND
Day > '2022-07-24';

SELECT
*
FROM
Reservations r
INNER JOIN
Customers c
ON
c.CustomerID = r.CustomerID
WHERE
(c.LastName = 'Norby'
OR
c.FirstName = 'Norby')
AND
r.Date > '2022-07-22';

DELETE
FROM
Reservations
WHERE
ReservationID = 2000;
16 changes: 15 additions & 1 deletion 01_restaurant/challenges/01_07_attendevent_ch.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
-- Register a customer for our Anniversary event.

-- The customer 'atapley2j@kinetecoinc.com' will be in
-- attendance, and will bring 3 friends.
-- attendance, and will bring 3 friends.

INSERT INTO
AnniversaryParty (CustomerID, Party)
VALUES (
(SELECT
c.CustomerID
FROM
Customers c
WHERE
c.Email = 'atapley2j@kinetecoinc.com'),
8);
Select * FROM AnniversaryParty;


21 changes: 20 additions & 1 deletion 01_restaurant/challenges/01_08_findreservation_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,23 @@
-- Variations of the name include:
-- Stevensen, Stephensen, Stevenson, Stephenson, Stuyvesant

-- There are four people in the party. Today is June 14th.
-- There are four people in the party. Today is June 14th.

SELECT
r.ReservationID,
c.FirstName||' '||c.LastName as [Reservation Name],
r.PartySize,
r.Date

FROM
Reservations r
INNER JOIN
Customers c
ON
r.CustomerID = c.CustomerID

WHERE
c.LastName LIKE 'St%'
AND
r.Date LIKE '%06-14%'
;
157 changes: 156 additions & 1 deletion 01_restaurant/challenges/01_09_createreservation_ch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,159 @@

-- Use the following information:
-- Sam McAdams (smac@kinetecoinc.com), for 5 people
-- on August 12, 2022 at 6PM (18:00)
-- on August 12, 2022 at 6PM (18:00)


/*
Holy fuck stick. I tried over and over to get this going in one statement, but could never get it to work.
The instructor did it in 3 separate statements, which was SO MUCH EASIER!! I could have done that.

Here:
*/

SELECT
CustomerID
FROM
Customers
WHERE
Email = 'smac@kinetecoinc.com';
/* no answer, because it doesn't exist yet.
So add him to Customers */

INSERT INTO
Customers (FirstName, LastName, Email)
VALUES ('Sam', 'McAdams', 'smac@kinetecoinc.com');

SELECT *
FROM Customers
ORDER BY CustomerID Desc
LIMIT 5;
/* Now customer exists. ID 102...
So add his reservation */

INSERT INTO
Reservations (CustomerID, Date, PartySize)
VALUES (102, '2022-08-12 18:00:00',5);

SELECT *
FROM
Reservations
ORDER BY
ReservationID DESC LIMIT 5;

-- -----------------------------

INSERT INTO
Customers (FirstName, LastName, Email)
Values ('Sam', 'McAdams', 'smac@kinetecoinc.com')
-- test for not existing:
WHERE NOT EXISTS (
SELECT 1
FROM
Customers
WHERE
Email = 'smac@kinetecoinc.com'
)
INSERT INTO
Reservations (CustomerID, Date, PartySize)
VALUES(
(SELECT
c.CustomerID
FROM
Customers c
WHERE
c.Email = 'smac@kinetecoinc.com'), '2022-08-12 18:00:00',5);

SELECT * FROM Customers ORDER BY CustomerID DESC LIMIT 10;

SELECT * From Reservations ORDER BY Date Desc Limit 10;



-- -------------------------------
IF EXISTS
(SELECT 1
FROM
Customers c
INNER JOIN
Reservations r
ON
c.CustomerID = r.CustomerID
WHERE
c.Email = 'smac@kinetecoinc.com');


-- ---------------------------------------------------


IF EXISTS
(SELECT
c.CustomerID
FROM
Customers c
INNER JOIN
Reservations r
ON
c.CustomerID = r.CustomerID
WHERE
c.Email = 'smac@kinetecoinc.com')
BEGIN
-- if customer already exists, add them to the reservations
INSERT INTO
Reservations (CustomerID, Date, PartySize)
VALUES (c.CustomerID, '2022-08-12 18:00:00',5)
END
ELSE
-- If customer does not exist, create customer, then add reservation
INSERT INTO
Customers (FirstName, LastName, Email)
VALUES ('Sam','McAdams','smac@kinetecoinc.com')
-- now add reservation for new customer
BEGIN
INSERT INTO
Reservations (CustomerID, Date, PartySize)

VALUES(
(SELECT
c.CustomerID
FROM
Customers c
INNER JOIN
Reservations r
ON
c.CustomerID = r.CustomerID
WHERE
c.Email = 'smac@kinetecoinc.com'),
'2022-08-12 18:00:00',5)
END;

SELECT * FROM Customers ORDER BY CustomerID DESC LIMIT 10;

SELECT * From Reservations ORDER BY Date Desc Limit 10;


(SELECT
c.CustomerID
FROM
Customers c
WHERE
c.Email = 'smac@kinetecoinc.com')


INSERT INTO
Reservations (CustomerID, Date, PartySize)

VALUES(
(SELECT
c.CustomerID
FROM
Customers c
INNER JOIN
Reservations r
ON
c.CustomerID = r.CustomerID
WHERE
c.Email = 'smac@kinetecoinc.com'),
'2022-08-12 18:00:00',5);

Select * FROM Reservations ORDER BY Date DESC;
Loading