SQLNinja Electronics Database Schema
Now, go ahead and write your query or copy one from the materials provided to test the output in real time. Below, you'll find all the key tables to help you experiment with different queries. Happy Querying!!
products
Field Name (Constraints) |
Data Type |
Description |
product_id (Primary Key) |
Integer |
Unique identifier for each product |
product_name |
String |
Name of the product |
category |
String |
Category to which the product belongs (e.g. Smartphone) |
brand |
String |
Brand/manufacturer of the product |
price |
Decimal |
Sale price of the product |
stock_quantity |
Integer |
Number of items available in stock |
discount |
Integer |
Discount percentage applied to the product |
product_id |
product_name |
category |
brand |
price |
stock_quantity |
discount |
1 |
iPhone 13 |
Smartphone |
Apple |
599 |
30 |
5 |
2 |
Galaxy S21 |
Smartphone |
Samsung |
420 |
50 |
10 |
3 |
Pixel 5a |
Smartphone |
Google |
160 |
25 |
0 |
4 |
MacBook Pro 13 |
Laptop |
Apple |
1299 |
15 |
10 |
5 |
XPS 13 |
Laptop |
Dell |
899 |
20 |
5 |
6 |
WH-1000XM4 |
Headphone |
Sony |
350 |
40 |
15 |
customers
Field Name (Constraints) |
Data Type |
Description |
customer_id (Primary Key) |
Integer |
Unique identifier for each customer |
first_name |
String |
First name of the customer |
last_name |
String |
Last name of the customer |
email |
String |
Email address of the customer |
phone |
String |
Phone number of the customer |
address |
String |
Address of the customer |
customer_id |
first_name |
last_name |
email |
phone |
address |
1 |
John |
Doe |
john.doe@example.com |
555-0101 |
123 Elm St, Springfield, IL |
2 |
Jane |
Smith |
jane.smith@example.com |
555-0102 |
456 Oak St, Springfield, IL |
3 |
Michael |
Johnson |
michael.j@example.com |
555-0103 |
789 Pine St, Centerville, CA |
4 |
Emily |
Davis |
emily.d@example.com |
555-0104 |
321 Maple St, Centerville, CA |
5 |
Daniel |
Garcia |
daniel.g@example.com |
555-0105 |
654 Cedar St, Lakeview, NY |
orders
Field Name (Constraints) |
Data Type |
Description |
order_id (Primary Key) |
Integer |
Unique identifier for each order |
customer_id (Foreign Key) |
Integer |
Identifier linking to the customer placing the order |
order_date |
Date |
Date when the order was placed |
total_amount |
Decimal |
Total amount for the order |
order_id |
customer_id |
order_date |
total_amount |
1 |
10 |
2022-11-11 |
3398 |
2 |
17 |
2023-07-20 |
399 |
3 |
1 |
2024-03-25 |
600 |
4 |
4 |
2022-07-03 |
650 |
5 |
11 |
2023-06-20 |
1349 |
orderdetails
Field Name (Constraints) |
Data Type |
Description |
order_detail_id (Primary Key) |
Integer |
Unique identifier for each order detail entry |
order_id (Foreign Key) |
Integer |
Identifier linking to the order |
product_id (Foreign Key) |
Integer |
Identifier linking to the product being ordered |
quantity |
Integer |
Number of units of the product ordered |
amount |
Decimal |
Total amount for the ordered product |
order_detail_id |
order_id |
product_id |
quantity |
amount |
528 |
1 |
46 |
1 |
1699 |
734 |
1 |
60 |
1 |
1699 |
1040 |
2 |
8 |
1 |
399 |
1456 |
3 |
22 |
1 |
600 |
489 |
4 |
27 |
1 |
650 |
reviews
Field Name (Constraints) |
Data Type |
Description |
review_id (Primary Key) |
Integer |
Unique identifier for each review entry |
order_detail_id (Foreign Key) |
Integer |
Unique identifier for each order detail entry |
customer_id (Foreign Key) |
Integer |
Identifier linking to the reviewing customer |
rating |
Integer |
Rating score given by the customer (e.g. 1 to 5) |
comment |
String |
Additional comments provided by the customer |
review_id |
product_id |
order_detail_id |
customer_id |
rating |
comment |
1 |
40 |
1639 |
1 |
2 |
Expected more based on the price. |
2 |
4 |
1920 |
1 |
1 |
Completely unsatisfactory, would not recommend. |
3 |
54 |
5736 |
1 |
4 |
Pretty good, but there's room for improvement. |
4 |
26 |
1056 |
2 |
5 |
Absolutely perfect, couldn't be happier! |
5 |
10 |
1847 |
2 |
4 |
Impressed, but not without its faults. |
suppliers
Field Name (Constraints) |
Data Type |
Description |
supplier_id (Primary Key) |
Integer |
Unique identifier for each supplier |
supplier_name |
String |
Name of the supplier |
contact |
String |
Contact details of the supplier |
address |
String |
Address of the supplier |
supplier_id |
supplier_name |
contact |
address |
1 |
Tech Gadgets Ltd. |
Jane Doe |
123 Tech Lane, Silicon Valley |
2 |
Global Electronics |
John Smith |
456 Global St, New York |
3 |
Smart Solutions Inc. |
Emily White |
789 Solutions Blvd, Boston |
4 |
Green Energy Co. |
Alex Green |
101 Energy Road, Austin |
5 |
Innovate IT |
Michael Brown |
202 Innovate Ave, Seattle |
shipments
Field Name (Constraints) |
Data Type |
Description |
shipment_id (Primary Key) |
Integer |
Unique identifier for each shipment entry |
supplier_id (Foreign Key) |
Integer |
Identifier linking to the supplier of the product |
product_id (Foreign Key) |
Integer |
Identifier linking to the shipped product |
quantity |
Integer |
Number of units of the product shipped |
date |
Date |
Date of the shipment |
shipment_id |
supplier_id |
product_id |
quantity |
date |
1 |
9 |
23 |
8 |
2023-04-04 |
2 |
10 |
12 |
15 |
2022-09-20 |
3 |
2 |
18 |
16 |
2023-07-27 |
4 |
9 |
14 |
19 |
2022-03-09 |
5 |
10 |
5 |
5 |
2023-06-07 |
test