{"id":24019971,"url":"https://github.com/dogan-the-analyst/Model_Car_Warehouse_Analysis","last_synced_at":"2026-07-25T01:30:25.859Z","repository":{"id":269348470,"uuid":"907111680","full_name":"dogan-the-analyst/Analyze_Data_in_a_Model_Car_Database","owner":"dogan-the-analyst","description":"This is a SQL project.","archived":false,"fork":false,"pushed_at":"2024-12-23T09:48:54.000Z","size":312,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T11:56:21.622Z","etag":null,"topics":["data-analysis","mysql","sql"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dogan-the-analyst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-22T20:55:22.000Z","updated_at":"2024-12-30T18:04:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"71d3d8b4-5ef8-4743-8a41-77741a67ac50","html_url":"https://github.com/dogan-the-analyst/Analyze_Data_in_a_Model_Car_Database","commit_stats":null,"previous_names":["dogan-the-analyst/analyze_data_in_a_model_car_database"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogan-the-analyst%2FAnalyze_Data_in_a_Model_Car_Database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogan-the-analyst%2FAnalyze_Data_in_a_Model_Car_Database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogan-the-analyst%2FAnalyze_Data_in_a_Model_Car_Database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogan-the-analyst%2FAnalyze_Data_in_a_Model_Car_Database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dogan-the-analyst","download_url":"https://codeload.github.com/dogan-the-analyst/Analyze_Data_in_a_Model_Car_Database/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240761141,"owners_count":19853256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analysis","mysql","sql"],"created_at":"2025-01-08T11:55:03.890Z","updated_at":"2026-07-25T01:30:25.721Z","avatar_url":"https://github.com/dogan-the-analyst.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analyze Data in a Model Car Database\n\n- The database used in project is `mintclassicsDB.sql` file. I prefered **MySQL Workbench** in this study. So, using the \"Import from Self-Contained File\" option from the Data Import tool, use the script to create the Mint Classic database on your MySQL Workbench platform.\n\n- You can find SQL queries in the `sql` folder and queries result in the `csv` folder.\n\n- ER Diagram of the db is below.\n\n\u003cbr\u003e\n\n![alt text](image.png)\n\n## First Look at the Project\n\n### Project Scenario\n\n**Mint Classics Company**, a retailer of classic model cars and other vehicles, is looking at closing one of their storage facilities. \n\nTo support a data-based business decision, they are looking for suggestions and recommendations for reorganizing or reducing inventory, while still maintaining timely service to their customers. For example, they would like to be able to ship a product to a customer within 24 hours of the order being placed.\n\n### Project Objectives\n\n1. Explore products currently in inventory.\n\n2. Determine important factors that may influence inventory reorganization/reduction.\n\n3. Provide analytic insights and data-driven recommendations.\n\n## SQL Queries to Understand Data and Make Some Conclusions\n\n### 1st Query: \n- To see the relationship between warehouse name and stock availability, this SQL query will help. The figure shows that the largest warehouse is `East` and the smallest one is `South`. You can also see that storage percentage of these. In terms of availability `West` seems to be good.  On the other hand `North` and `South` are close to full.\n\n```sql\nSELECT \n    w.warehouseCode,\n    w.warehouseName,\n    COUNT(p.productCode) AS totalProducts,\n    SUM(p.quantityInStock) AS totalQuantityInStock,\n    w.warehousePctCap AS storagePercentage,\n    FLOOR(SUM(p.quantityInStock) * (100 - w.warehousePctCap) / 100) AS stockAvailability\nFROM \n    products p \nLEFT JOIN \n    warehouses w \nON \n    w.warehouseCode = p.warehouseCode\nGROUP BY\n    w.warehouseCode, \n    w.warehouseName\nORDER BY\n    totalQuantityInStock DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result1-1.png)\n---\n### 2nd Query:\n- Using this query, I want to find out which warehouses contain which product types, and also how much of each they contain. To summarize: `East` contains only `Classic Cars` while `West` contains only `Vintage Cars`. `North` contains both `Motorcycles` and `Planes`. `South` has by itself three of all product types, namely `Trucks and Buses`, `Ships` and `Trains`.  \n\n```sql\nSELECT\n    w.warehouseName,\n    p.productLine,\n    SUM(p.quantityInStock) AS totalStock\nFROM\n    products p\nLEFT JOIN\n    warehouses w\nON\n    w.warehouseCode = p.warehouseCode\nGROUP BY\n    w.warehouseName,\n    p.productLine\nORDER BY \n    totalStock DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result2-1.png)\n---\n### 3rd Query:\n- To find out which type of product is most popular in terms of total quantity ordered, I ran this query. As you can see `Classics Cars` is in first place and `Trains` in last place.\n\n\n```sql\nSELECT\n    p.productLine,\n    SUM(od.quantityOrdered) AS totalQuantityOrdered\nFROM \n    orderdetails od\nLEFT JOIN\n    products p\nON \n    p.productCode = od.productCode\nGROUP BY\n    p.productLine\nORDER BY\n    totalQuantityOrdered DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result3-1.png)\n---\n### 4th Query:\n- Most of the orders come from `East`.\n\n```sql\nSELECT \n    w.warehouseCode,\n    w.warehouseName, \n    COUNT(od.orderNumber) AS totalOrders, \n    SUM(od.quantityOrdered) AS totalQuantityOrdered\nFROM \n    warehouses w\nJOIN \n    products p \nON \n    w.warehouseCode = p.warehouseCode\nJOIN \n    orderdetails od \nON \n    p.productCode = od.productCode\nGROUP BY \n    w.warehouseCode, \n    w.warehouseName\nORDER BY \n    totalQuantityOrdered DESC;\n```\n\n\u003cbr\u003e\n\n![alt text](result4-1.png)\n---\n### 5th Query:\n- To answer how many orders come from which country, this query will help us. The USA is by far in first place. The next countries are France, Spain and Australia.\n\n```sql\nSELECT \n    customers.country,\n    COUNT(customers.country) AS totalOrder\nFROM\n    orders\nLEFT JOIN\n    customers\nON \n    customers.customerNumber = orders.customerNumber\nGROUP BY\n    customers.country\nORDER BY\n    totalOrder DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result5-1.png) \n---\n### 6th Query:\n- Here we can see the most popular product is `192 Ferrari 360 Spider red`, which is located in `East` warehouse.\n\n```sql\nSELECT \n    p.productName,\n    p.productLine,\n    p.warehouseCode,\n    SUM(od.quantityOrdered) AS totalOrdered,\n    p.quantityInStock\nFROM \n    products p\nLEFT JOIN \n    orderdetails od \nON \n    p.productCode = od.productCode\nGROUP BY \n    p.productCode, \n    p.productName\nORDER BY \n    totalOrdered DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result6-1.png)\n---\n### 7th Query:\nTo answer how many customers live in which country, this query will help us. Customers who are living in USA are by far in first place. The next countries are Germany, France and Spain.\n\n```sql\nSELECT \n    country,\n    COUNT(customerNumber) AS totalCustomer\nFROM \n    customers\nGROUP BY\n    country\nORDER BY\n    totalCustomer DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result7-1.png)\n---\n### 8th Query:\n- I wondered that the difference between the order date and the shipping date, so I wrote this query. The result is devistating because some of the orders, not all, that come from Singapore has 65 days delay of shipping. If you look more closely you can see all of these belongs order number of 10165. You can check the full result in the folder of `csv`.\n\n```sql\nSELECT \n    o.orderNumber,\n    o.orderDate,\n    o.shippedDate,\n    DATEDIFF(o.shippedDate, o.orderDate) AS dateDifference,\n    p.productLine,\n    w.warehouseName,\n    c.country\nFROM \n    orders o\nLEFT JOIN \n    orderdetails od \nON \n    od.orderNumber = o.orderNumber\nLEFT JOIN\n    products p\nON\n    p.productCode = od.productCode\nLEFT JOIN \n    warehouses w\nON\n    w.warehouseCode = p.warehouseCode\nLEFT JOIN\n    customers c\nON\t\n    c.customerNumber = o.customerNumber\nORDER BY \n    dateDifference DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result8-1.png)\n---\n### 9th Query:\n- Ninth query was made for seeing product shortage in terms of the number of total order and product's quantities in recent stock. Some of the products located in `North` are in first 4 rows.\n\n```sql\nSELECT \n    p.productName,\n    p.productLine,\n    p.warehouseCode,\n    SUM(od.quantityOrdered) AS totalOrdered,\n    p.quantityInStock\nFROM \n    products p\nLEFT JOIN \n    orderdetails od \nON \n    p.productCode = od.productCode\nGROUP BY \n    p.productCode, \n    p.productName\nHAVING \n    totalOrdered \u003e quantityInStock\nORDER BY \n    totalOrdered DESC\n;\n```\n\n\u003cbr\u003e\n\n![alt text](result9-1.png)   \n---\n### 10th Query:\n- Finally, this query shows us that the amount of some products in the company's inventory are extremely high. These numbers should come down. For example, if you look at the `1995 Honda Civic` which has been ordered 917 times but it's quantity in stock is nearly 11 times higher than the number of it's orders.   \n\n\n```sql\nSELECT \n    p.productName,\n    p.productLine,\n    p.warehouseCode,\n    SUM(od.quantityOrdered) AS totalOrdered,\n    p.quantityInStock,\n    ROUND((100 * p.quantityInStock) / SUM(od.quantityOrdered)) AS overStockPercentage\nFROM \n    products p\nLEFT JOIN \n    orderdetails od \nON \n    p.productCode = od.productCode\nGROUP BY \n    p.productName\nORDER BY \n    overStockPercentage DESC\n;\n```\n\u003cbr\u003e\n\n![alt text](result10-1.png)\n\n## Recommendations \n1. Considering the storage percentages of the warehouses, the company might consider closing the `South` and moving its inventory to the `East`, `North` and `West`.\n2. Some of the products are in short supply. For example, `F/A 18 Hornet 1/72` and `1960 BSA Gold Star DBD34`. They should be increased. Otherwise, the difference between the order date and the shipping date would be higher due to supply.\n3. First and foremost, the products in the `East` and `North` warehouses should be reduced immediately. They and other products like them represent unnecessary inventory. Such inventory items cause unnecessary costs for the company.\n4. The company can open new offices in `Spain` and `Germany`. Due to the results of 5th and 7th queries. `Spain` is the third country with the most orders. And `Germany` is the second country with the most customers.\n5. It should be investigated what are the key factors behind the 65 days difference between the order date and the shipping date (order `10165`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogan-the-analyst%2FModel_Car_Warehouse_Analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdogan-the-analyst%2FModel_Car_Warehouse_Analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogan-the-analyst%2FModel_Car_Warehouse_Analysis/lists"}