Tables
Tables
Products Information:
Store details about various products, including product ID, name, description, and price.
Customer Information:
Maintain customer records with a unique customer ID, first name, last name, password, email,
and address.
Order Processing:
Track orders with an order ID, customer ID, product ID, order date, order status, and total
amount.
Payment Transactions:
Record payment information, including payment ID, amount, payment date, payment method,
order ID, and customer ID.
Sales Data:
Capture sales data, including sales ID, product ID, quantity sold, and total revenue generated.
Shopping Cart Management:
Manage shopping carts, recording cart ID, total items, and total price.
Customer Reviews:
Allow customers to provide reviews, including review ID, customer ID, product ID, rating, and
customer name.
Admin Users:
Store information about admin users, including admin ID, username, password, and email.
Discounted Products:
Maintain a list of discounted products with details such as product ID, name, initial price, and
discounted price.
Stock Levels:
Track stock levels for each product, including product ID, name, and quantity available.
Supplier Information:
Store details about suppliers, including supplier ID, name, and address.
Order Status Tracking:
Keep track of order statuses, such as 'Processing,' 'Shipped,' and 'Delivered.'
Customer Feedback Analysis:
Analyze customer feedback by tracking reviews and ratings for products.
Admin Authentication:
Implement a system for admin user authentication to ensure secure access.
Top Products and Revenue:
Identify and display top-selling products and calculate overall revenue.
=========================================================================================
---(Tables)---
=========================================================================================
Output:
Output:
--(6). Shopping cart table
create table shopping_cart (
cart_id int primary key,
total_items int,
total_price decimal
);
insert into shopping_cart (cart_id, total_items, total_price) values
(134, 3, 1729.65),
(256, 2, 899.98),
(334, 1, 129.99),
(478, 1, 999.99),
(545, 2, 1799.98),
(656, 5, 479.94),
(457, 1, 249.99);
select *from shopping_cart;
Output:
Output:
Output:
======================================================================
---(Queries)---
======================================================================
---------------------------------------------------------------------------------
/* Here is the queries for the Product and customer table */
---------------------------------------------------------------------------------
Output:
Output:
--(3). Count the total number of products in the "product" table.
select count(product.product_id) as total_Product from product;
Output:
Output:
--(6). Shows the product with their name entered by the user, But it runs only
when the user input the specific name.
SELECT product_id, product_name, price, description_product
FROM product
WHERE product_name IN ('Laptop', 'Smartphone', 'Headphones', '4K TV', 'Digital
Camera', 'Robot Vacuum');
Output:
---------------------------------------------------------------------------------
/* Here is the queries for the Order table */
---------------------------------------------------------------------------------
Output:
--(9). Showing the details of customer and product having more then two order
select
customer111.first_name,
customer111.last_name,
customer111.c_address,
product.product_name,
product.price,
count(order_table121.order_id)
as
Counted_order
from
customer111
inner join
order_table121 on customer111.customer_id = order_table121.order_id
inner join
product on product.product_id = order_table121.order_id
group by
customer111.first_name, customer111.last_name, customer111.c_address,
product.product_name, product.price
having
count(order_table121.order_id) >2;
Output:
--(10) Displaying the details as which customers buy which product
select
customer111.first_name,
customer111.last_name,
customer111.c_address,
product.product_name,
product.price
from
customer111
inner join
order_table121 on customer111.customer_id = order_table121.order_id
inner join
product on product.product_id = order_table121.order_id;
Output:
--(11). Showing the details of the customers and product that have dilevered,
processing and shipping the order
select
customer111.customer_id,
customer111.first_name,
customer111.last_name,
product.product_id,
product.product_name,
product.price
from
customer111
inner join
order_table121 on order_table121.customer_id = customer111.customer_id
inner join
product on order_table121.product_id = product.product_id
where
order_table121.status = 'Delivered';
Output:
Output:
---------------------------------------------------------------------------------
/* Here is the queries for stock table */
---------------------------------------------------------------------------------
Output:
Output:
---------------------------------------------------------------------------------
/* Here is the queries for ADMIN table */
---------------------------------------------------------------------------------
Output:
---------------------------------------------------------------------------------
/* Here is the queries for the Sales table */
---------------------------------------------------------------------------------
Output:
---------------------------------------------------------------------------------
/* Here is the queries for the Payment table */
---------------------------------------------------------------------------------
--(1). Displays the total payment methods
select count(distinct payment.payment_method) as total_payment_methods from
payment;
Output:
Output:
--(5). Showing the details of the customers that have to payment more then two
times
select
customer111.customer_id,
customer111.first_name,
customer111.last_name,
customer111.c_address,
count(payment.payment_id)
as
counted_payment
from
customer111
inner join
payment on payment.customer_id = customer111.customer_id
group by
customer111.customer_id,
customer111.first_name,
customer111.last_name,
customer111.c_address
having
count(payment.payment_id) > 2;
Output:
--(6). Showing the details as "The customer that buy a product, order this
product and pay the payment for it"
select
customer111.first_name,
customer111.last_name,
product.product_name,
product.price,
order_table121.order_date,
order_table121.status,
order_table121.total_amount,
payment.payment_date,
payment.payment_method
from
customer111
inner join
order_table121 on order_table121.customer_id = customer111.customer_id
inner join
product on order_table121.product_id = product.product_id
inner join
payment on payment.order_id = order_table121.order_id;
---------------------------------------------------------------------------------
/* Here is the queries for the Review table */
---------------------------------------------------------------------------------
--(2) It shows the details of the customers and products that are reviewed
select
review.review_id,
customer111.first_name,
customer111.last_name,
product.product_name,
review.rating
from
review
inner join
customer111 on review.customer_id = customer111.customer_id
inner join
product on review.product_id = product.product_id;
Output:
Output:
---------------------------------------------------------------------------------
/* Here are the queries for the Shopping cart table */
---------------------------------------------------------------------------------
--(1). Display total items and prices for each shopping cart
select cart_id, total_items, total_price
from shopping_cart;
Output:
--(4). Display the details of the shopping cart with the highest total items
select *from shopping_cart
order by total_items desc;
Output:
--(5). Show shopping carts with a total price between $100 and $500
select cart_id, total_items, total_price
from shopping_cart
where total_price between 100 and 500;
Output:
---------------------------------------------------------------------------------
/* Here are the queries for the Discounted Products Table */
---------------------------------------------------------------------------------
--(1). Display all discounted products with their prices
select product_id, product_name, initial_price, discounted_price
from discounted_products;
Output:
---------------------------------------------------------------------------------
/* Here are the queries for the Discounted Products Table */
---------------------------------------------------------------------------------
--(1). Display the total number of suppliers
select count(supplier_id) as total_suppliers
from suppliers;
Output:
order_table121 discounted_products
order_id product_id
customer_id product_name
product_id initial_price
order_date discounted_price
status
total_amount
customer111
customer_id
first_name
last_name
product
password
product_id stock
email product_id
product_name
c_address
payment description_product
product_name
payment_id product_quantity
price
amount
payment_date
payment_method
order_id
review customer_id
review_id
sales
customer_id
sales_id
customer_name
product_id
rating
quantity_sold
product_id
total_revenue