Fundamental and Advanced SQL queries for questions on Premier Products Data set. The questions are mentioned as comments in the sql file followed by the queries.
- About Premier Products Data Set
- Steps to Import Database File
- ER Diagram
- Project Description
- Author
- License
- Acknowledgments
The database consists of following tables -
- customer
- order_line
- orders
- part
- rep
- customer
- Primary Key: customer_num
- Table provides details about a customer. Each row contains address details of a unique customer identified by a customer_num. Each customer is served by a service rep. A service rep could be assigned to multiple customers in a region.
- order_line
- Candidate Key: order_num
- Candidate Key: part_num
- Composite Primary Key: (order_num, part_num)
- Table provides details about an order. The table may contain multiple rows for each order. Each order is identified by an order_num and each order could consists of multiple parts. The order_num and part_num together forms a primary key for this table.
- orders
- Primary Key: order_num
- Table provides details about an order. The table contains one row for each order. Each order is identified by an order_num.
- part
- Primary Key: part_num
- Table provides details about a part. The table contains one row for each part and a part is uniquely identified by a part_num. Each row consists of part description, warehouse inventory, price, and category.
- rep
- Primary Key: rep_num
- Table provides details about a sales representative. The table contains one row for each rep and a rep is uniquely identified by a rep_num. Each row contains address details, region served by the rep, and commission charged.
- Create a new database within pgadmin server and give it a name.
- Right-click on the new database then select 'Restore'.
- Import Premier Products Database file.
- Select 'Restore' to start restoring the database.
-
Premier_Product_Basic.sql contains queries that use - where, order by, inner join
-
Premier_Product_Fundamental.sql contains queries that use - OR, IN, order by, having, group by
-
Premier_Product_Advanced.sql contains queries that use - Inner join, Nested Queries, exists, LIKE, And, OR, full join
The MIT License (MIT)
Copyright (c) 2023 Abbas Singapurwala
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Inspiration, code snippets, etc.