college/Spring-2024/CS-1011/Relational-DB-Assignment/README.org

56 lines
2.1 KiB
Org Mode
Raw Normal View History

* Databases: Relational - In-Class Assignment
You can run the queries in [[./solve.sql]] against a ~sqlite3~ database to solve this assignment
or install [[https://nixos.org/][Nix]] and run [[./solve.bash]].
** Answer the Following Questions With Info From [[*Tables]]
1. What was the total profit across all stores?
- =$34.5=
2. What is the name of the most popular product sold?
- =Toy Story=
3. How much profit did the "East" region make?
- =$13.96=
4. Which city had the highest cost?
- The city with the highest aggregate cost would be =San Francisco=.
- However, the city with the highest /single/ cost would be =New York=.
5. What was the least popular product brand?
- =Big Studios=, because they had no sales.
6. Which city (or cities) sold "Sense and Sensibility"?
- =San Francisco=
** Tables
*** STORE
| Store_key | City | Region |
|-----------|---------------|---------|
| 1 | New York | East |
| 2 | Chicago | Central |
| 3 | Atlanta | East |
| 4 | Los Angeles | West |
| 5 | San Francisco | West |
| 6 | Philadelphia | East |
*** PRODUCT
| Product_key | Description | Brand |
|-------------|-----------------------|-----------------|
| 1 | Beautiful Girls | MKF Studios |
| 2 | Toy Story | Wolf |
| 3 | Sense and Sensibility | Parabuster Inc. |
| 4 | Holday of the Year | Wolf |
| 5 | Pulp Fiction | MKF Studios |
| 6 | The Juror | MKF Studios |
| 7 | From Dusk Till Dawn | Parabuster Inc. |
| 8 | Hellraiser: Bloodline | Big Studios |
*** SALES_FACT
| Store_key | Product_key | Sales | Cost | Profit |
|-----------|-------------|-------|------|--------|
| 1 | 6 | 2.39 | 1.15 | 1.24 |
| 1 | 2 | 16.7 | 6.91 | 9.79 |
| 2 | 7 | 7.16 | 2.75 | 4.40 |
| 3 | 2 | 4.77 | 1.84 | 2.93 |
| 5 | 3 | 11.93 | 4.59 | 7.34 |
| 5 | 1 | 14.31 | 5.51 | 8.80 |