Skip to content

Commit 6175206

Browse files
authored
Update Challenge 5 - Pub pricing analysis.md
1 parent b7378af commit 6175206

File tree

1 file changed

+94
-1
lines changed

1 file changed

+94
-1
lines changed

Challenge 5 - Pub pricing analysis.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,100 @@ Here are the tables I created and used in MySQL Workbench 8.0:
1313

1414
## Table Creation:
1515
```sql
16-
-- SQL code to create the required tables
16+
USE STEEL_DATA;
17+
CREATE TABLE pubs (
18+
pub_id INT PRIMARY KEY,
19+
pub_name VARCHAR(50),
20+
city VARCHAR(50),
21+
state VARCHAR(50),
22+
country VARCHAR(50)
23+
);
24+
25+
-- Create the 'beverages' table
26+
CREATE TABLE beverages (
27+
beverage_id INT PRIMARY KEY,
28+
beverage_name VARCHAR(50),
29+
category VARCHAR(50),
30+
alcohol_content FLOAT,
31+
price_per_unit DECIMAL(8, 2)
32+
);
33+
34+
-- Create the 'sales' table
35+
CREATE TABLE sales (
36+
sale_id INT PRIMARY KEY,
37+
pub_id INT,
38+
beverage_id INT,
39+
quantity INT,
40+
transaction_date DATE,
41+
FOREIGN KEY (pub_id) REFERENCES pubs(pub_id),
42+
FOREIGN KEY (beverage_id) REFERENCES beverages(beverage_id)
43+
);
44+
45+
-- Create the 'ratings' table
46+
CREATE TABLE ratings (
47+
rating_id INT PRIMARY KEY,
48+
pub_id INT,
49+
customer_name VARCHAR(50),
50+
rating FLOAT,
51+
review TEXT,
52+
FOREIGN KEY (pub_id)
53+
REFERENCES pubs (pub_id)
54+
);
55+
--------------------
56+
-- Insert sample data into the 'pubs' table
57+
INSERT INTO pubs (pub_id, pub_name, city, state, country)
58+
VALUES
59+
(1, 'The Red Lion', 'London', 'England', 'United Kingdom'),
60+
(2, 'The Dubliner', 'Dublin', 'Dublin', 'Ireland'),
61+
(3, 'The Cheers Bar', 'Boston', 'Massachusetts', 'United States'),
62+
(4, 'La Cerveceria', 'Barcelona', 'Catalonia', 'Spain');
63+
64+
-- Insert sample data into the 'beverages' table
65+
INSERT INTO beverages (beverage_id, beverage_name, category, alcohol_content, price_per_unit)
66+
VALUES
67+
(1, 'Guinness', 'Beer', 4.2, 5.99),
68+
(2, 'Jameson', 'Whiskey', 40.0, 29.99),
69+
(3, 'Mojito', 'Cocktail', 12.0, 8.99),
70+
(4, 'Chardonnay', 'Wine', 13.5, 12.99),
71+
(5, 'IPA', 'Beer', 6.8, 4.99),
72+
(6, 'Tequila', 'Spirit', 38.0, 24.99);
73+
74+
INSERT INTO sales (sale_id, pub_id, beverage_id, quantity, transaction_date)
75+
VALUES
76+
(1, 1, 1, 10, '2023-05-01'),
77+
(2, 1, 2, 5, '2023-05-01'),
78+
(3, 2, 1, 8, '2023-05-01'),
79+
(4, 3, 3, 12, '2023-05-02'),
80+
(5, 4, 4, 3, '2023-05-02'),
81+
(6, 4, 6, 6, '2023-05-03'),
82+
(7, 2, 3, 6, '2023-05-03'),
83+
(8, 3, 1, 15, '2023-05-03'),
84+
(9, 3, 4, 7, '2023-05-03'),
85+
(10, 4, 1, 10, '2023-05-04'),
86+
(11, 1, 3, 5, '2023-05-06'),
87+
(12, 2, 2, 3, '2023-05-09'),
88+
(13, 2, 5, 9, '2023-05-09'),
89+
(14, 3, 6, 4, '2023-05-09'),
90+
(15, 4, 3, 7, '2023-05-09'),
91+
(16, 4, 4, 2, '2023-05-09'),
92+
(17, 1, 4, 6, '2023-05-11'),
93+
(18, 1, 6, 8, '2023-05-11'),
94+
(19, 2, 1, 12, '2023-05-12'),
95+
(20, 3, 5, 5, '2023-05-13');
96+
97+
-- Insert sample data into the 'ratings' table
98+
INSERT INTO ratings (rating_id, pub_id, customer_name, rating, review)
99+
VALUES
100+
(1, 1, 'John Smith', 4.5, 'Great pub with a wide selection of beers.'),
101+
(2, 1, 'Emma Johnson', 4.8, 'Excellent service and cozy atmosphere.'),
102+
(3, 2, 'Michael Brown', 4.2, 'Authentic atmosphere and great beers.'),
103+
(4, 3, 'Sophia Davis', 4.6, 'The cocktails were amazing! Will definitely come back.'),
104+
(5, 4, 'Oliver Wilson', 4.9, 'The wine selection here is outstanding.'),
105+
(6, 4, 'Isabella Moore', 4.3, 'Had a great time trying different spirits.'),
106+
(7, 1, 'Sophia Davis', 4.7, 'Loved the pub food! Great ambiance.'),
107+
(8, 2, 'Ethan Johnson', 4.5, 'A good place to hang out with friends.'),
108+
(9, 2, 'Olivia Taylor', 4.1, 'The whiskey tasting experience was fantastic.'),
109+
(10, 3, 'William Miller', 4.4, 'Friendly staff and live music on weekends.');
17110
```
18111
## Ad-Hoc Questions and Solutions
19112
###1. How many pubs are located in each country?

0 commit comments

Comments
 (0)