Skip to content

Commit b73cb29

Browse files
feat: solved 1st stage of the Hyperskill project "Electronics Store Customer"
1 parent f9c0a31 commit b73cb29

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Objectives
2+
3+
Identify the `pc_code`, `model`, `speed`, and `ram` of PCs from the `market` database with 16 GB of RAM or more.
4+
5+
Ensure the results are sorted primarily by `ram` in ascending order and secondarily by `speed` in descending order.
6+
7+
The column order is essential.
8+
9+
```sql
10+
SELECT pc_code, model, speed, ram
11+
FROM PC
12+
WHERE ram >= 16
13+
ORDER BY ram ASC, speed DESC;
14+
```
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
DROP TABLE IF EXISTS PC;
2+
DROP TABLE IF EXISTS Laptop;
3+
DROP TABLE IF EXISTS Printer;
4+
DROP TABLE IF EXISTS Product;
5+
6+
-- Create the Product table
7+
CREATE TABLE Product (
8+
maker VARCHAR(50) NOT NULL,
9+
model INT NOT NULL,
10+
type VARCHAR(50) NOT NULL,
11+
PRIMARY KEY (model)
12+
);
13+
14+
-- Create the PC table
15+
CREATE TABLE PC (
16+
pc_code INT NOT NULL,
17+
model INT NOT NULL,
18+
speed INT NOT NULL,
19+
ram INT NOT NULL,
20+
hd INT NOT NULL,
21+
cd VARCHAR(50) NOT NULL,
22+
price DECIMAL(10, 2) NOT NULL,
23+
PRIMARY KEY (pc_code),
24+
FOREIGN KEY (model) REFERENCES Product(model) -- Define the foreign key relationship
25+
);
26+
27+
-- Create the Laptop table
28+
CREATE TABLE Laptop (
29+
laptop_code INT NOT NULL,
30+
model INT NOT NULL,
31+
speed INT NOT NULL,
32+
ram INT NOT NULL,
33+
hd INT NOT NULL,
34+
screen INT NOT NULL,
35+
price DECIMAL(10, 2) NOT NULL,
36+
PRIMARY KEY (laptop_code),
37+
FOREIGN KEY (model) REFERENCES Product(model) -- Define the foreign key relationship
38+
);
39+
40+
-- Create the Printer table
41+
CREATE TABLE Printer (
42+
printer_code INT NOT NULL,
43+
model INT NOT NULL,
44+
color CHAR(1) NOT NULL,
45+
type VARCHAR(50) NOT NULL,
46+
price DECIMAL(10, 2) NOT NULL,
47+
PRIMARY KEY (printer_code),
48+
FOREIGN KEY (model) REFERENCES Product(model) -- Define the foreign key relationship
49+
);
50+
51+
INSERT INTO Product (model, maker, type)
52+
VALUES
53+
(101, 'Sony', 'Laptop'),
54+
(102, 'Sony', 'PC'),
55+
(103, 'HP', 'Printer'),
56+
(104, 'LG', 'Laptop'),
57+
(105, 'LG', 'PC'),
58+
(106, 'Konica Minolta', 'Printer'),
59+
(107, 'Samsung', 'Laptop'),
60+
(108, 'IBM', 'PC'),
61+
(109, 'Sony', 'PC'),
62+
(110, 'Xerox', 'Printer');
63+
64+
INSERT INTO PC (pc_code, model, speed, ram, hd, cd, price)
65+
VALUES
66+
(201, 102, 2800, 8, 1000, 'DVD', 799.99),
67+
(202, 105, 3200, 16, 2000, 'Blu-ray', 1299.99),
68+
(203, 108, 2400, 4, 500, 'None', 549.99),
69+
(204, 109, 2600, 8, 1000, 'DVD', 699.99),
70+
(205, 102, 3500, 32, 1500, 'DVD', 1399.99),
71+
(206, 105, 2900, 8, 1000, 'DVD', 749.99),
72+
(207, 102, 2700, 4, 500, 'None', 599.99),
73+
(208, 109, 2800, 8, 1000, 'DVD', 699.99),
74+
(209, 102, 3300, 16, 2000, 'Blu-ray', 1199.99),
75+
(210, 105, 2600, 4, 500, 'DVD', 539.99);
76+
77+
INSERT INTO Laptop (laptop_code, model, speed, ram, hd, screen, price)
78+
VALUES
79+
(301, 101, 2500, 8, 512, 13, 1299.99),
80+
(302, 104, 2800, 16, 1000, 15, 1599.99),
81+
(303, 107, 2400, 4, 256, 14, 799.99),
82+
(304, 101, 2700, 16, 512, 13, 1399.99),
83+
(305, 107, 2600, 8, 512, 14, 1199.99),
84+
(306, 101, 2300, 4, 256, 13, 999.99),
85+
(307, 107, 2500, 8, 512, 14, 1299.99),
86+
(308, 101, 2900, 16, 1000, 15, 1699.99),
87+
(309, 104, 2600, 8, 512, 14, 1299.99),
88+
(310, 107, 4700, 32, 256, 16, 1999.99);
89+
90+
INSERT INTO Printer (printer_code, model, color, type, price)
91+
VALUES
92+
(401, 106, 'C', 'Inkjet', 249.99),
93+
(402, 103, 'B', 'Laser', 129.99),
94+
(403, 110, 'C', 'Laser', 299.99),
95+
(404, 103, 'B', 'Matrix', 139.99),
96+
(405, 103, 'C', 'Laser', 199.99),
97+
(406, 106, 'B', 'Inkjet', 119.99),
98+
(407, 103, 'C', 'Inkjet', 179.99),
99+
(408, 106, 'B', 'Laser', 109.99),
100+
(409, 110, 'C', 'Matrix', 279.99),
101+
(410, 103, 'B', 'Inkjet', 129.99),
102+
(411, 106, 'C', 'Inkjet', 169.99)
103+
;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Electronics Store Customer
2+
3+
My solution to the project [Electronics Store Customer](https://hyperskill.org/projects/382?track=40) on [Hyperskill](https://hyperskill.org).
4+
5+
Each stage of the project is in a separate folder.

hyperskill/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ My [certificate](https://hyperskill.org/certificates/e4756834-a763-4bf1-9cf4-3e1
5252

5353
There are no certificates for this track yet.
5454

55-
## Essential Skills for Backend Developers
55+
## Essential Skills for Backend Developers Track
5656

5757
[My](https://hyperskill.org/profile/7889902) solutions to [Hyperskill](https://hyperskill.org) projects from the [Essential Skills for Backend Developers](https://hyperskill.org/tracks/50) track.
5858

@@ -63,3 +63,13 @@ There are no certificates for this track yet.
6363
| [Dolly](./15_dolly) | Challenging | Completed |
6464

6565
My [certificate](https://hyperskill.org/certificates/2d7f557a-0541-4721-92a5-d1d35c1c2033.pdf) of completion of the track.
66+
67+
## SQL for Backend Developers Track
68+
69+
[My](https://hyperskill.org/profile/7889902) solutions to [Hyperskill](https://hyperskill.org) projects from the [SQL for Backend Developers](https://hyperskill.org/tracks/40) track.
70+
71+
| Project | Level | Status |
72+
| ------------------------------------------------------------- | ----- | ----------- |
73+
| [Electronics Store Customer](./16_electronics_store_customer) | Easy | In Progress |
74+
75+
My [certificate](TODO:) of completion of the track.

0 commit comments

Comments
 (0)