Ecommerce Database - Using PHP and MySQL BLOB (ER diagram is below)

Image thumbnails are 0.8% of original size; you can download full resolution by right-clicking/long tapping (depending on your device) the thumbnail and choosing "save as" or similar


First, let's do a complete overview of the database, which is a 5-table join but does NOT show childless parent rows:

select
  customers.customerID
 ,firstName
 ,lastName
 ,email
 ,password
 ,orders.orderID
 ,orderDate
 ,categories.categoryID
 ,categories.name "category_name"
 ,products.productID
 ,products.name
 ,orderDetails.quantity
 ,price
 ,orderDetails.quantity * price "lineTotal"
 ,products.product_image 
from 
  customers
 ,orders
 ,products
 ,orderDetails
 ,categories 
where
  orders.customerID=customers.customerID 
  and orders.orderID=orderDetails.orderID 
  and orderDetails.productID=products.productID 
  and products.categoryID=categories.categoryID

Database Overview, no childless parent rows shown

Customer ID First Name Last Name Email Password Order Id Order Date Category ID Category Name Product ID Product Name Quantity Price, US$ Line Item Total Product Image
1ChinLeefoo@barsecret12024-03-03 15:00:331Graphic Images1E-Book clip art1 $100.23 $100.23
2CindyShinfoo@barsecret42024-03-02 14:30:134Photography5Model Railroad3 $22.34 $67.02
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:521Graphic Images1E-Book clip art367 $100.23 $36784.41
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:523Other2Milk744 $10.32 $7678.08
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:523Other3Light Bulb, old fashioned incandescent (tungsten filament), generates lots of heat as well as light!4 $55.77 $223.08
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:523Other4Color Wheel8 $55.77 $446.16
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:524Photography5Model Railroad43 $22.34 $960.62
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:525Widgets6Extension Cord77 $22.34 $1720.18

Next, let's join customers (parent) to orders (child), showing customers with no orders having NULL for Order ID and Date:

select
  customers.customerID
  ,firstName
  ,lastName
  ,email
  ,password
  ,orderID
  ,orderDate 
from 
customers left outer join orders 
on orders.customerID=customers.customerID

Orders by Customer

Customer ID First Name Last Name Email Password Order Id Order Date
1ChinLeefoo@barsecret12024-03-03 15:00:33
1ChinLeefoo@barsecret22024-03-01 22:11:11
2CindyShinfoo@barsecret32024-03-01 05:55:45
2CindyShinfoo@barsecret42024-03-02 14:30:13
3JoeSchmome@abc.netchangeMe!52024-03-03 11:21:52
3JoeSchmome@abc.netchangeMe!82024-03-16 12:20:32
4AndySmithasmith@noyb.netNow why would I reveal that?

Next, let's join categories (parent) to products (child), showing categories with no products as NULL for product name:

select
   categories.categoryID
  ,categories.name "categoryName"
  ,products.productID
  ,products.name "productName" 
  ,products.product_image
from 
categories left outer join products 
on categories.categoryID=products.categoryID

Products by Category

Category ID Category Name Product ID Product Name Product Image
1Graphic Images1E-Book clip art
3Other2Milk
3Other3Light Bulb, old fashioned incandescent (tungsten filament), generates lots of heat as well as light!
3Other4Color Wheel
4Photography5Model Railroad
5Widgets6Extension Cord
6Future Category7Fururistic Product
7Brand New Category

Next, let's join products (parent) to orderDetails (child), showing products with no orderDetails as NULL for order date:

select
 products.productID
, products.name
, products.price
, products.categoryID
, orderDetails.orderID
, orderDetails.quantity
, orderDetails.order_details_date 
, products.product_image
from products 
left outer join orderDetails 
on orderDetails.productID = products.productID

Orders by Product

Product ID Product Name Product Price Category ID Order ID Quantity Order Date Product Image
1E-Book clip art100.231112024-03-02 08:22:55
1E-Book clip art100.23153672024-03-03 11:10:54
2Milk10.32357442024-03-03 11:10:54
3Light Bulb, old fashioned incandescent (tungsten filament), generates lots of heat as well as light!55.773542024-03-03 11:12:13
4Color Wheel55.773582024-03-03 11:12:13
5Model Railroad22.344432024-03-02 14:32:39
5Model Railroad22.3445432024-03-02 11:13:42
6Extension Cord22.3455772024-03-16 12:15:30
7Fururistic Product236.016

Next, let's join orders (parent) to orderDetails (child), showing orders with no orderDetails as NULL for Product ID, Quantity and Order Details Date:

select
 orders.orderID
, orders.customerID
, orders.orderDate
, orderDetails.productID
, orderDetails.quantity
, orderDetails.order_details_date 
from
 orders 
left outer join
 orderDetails 
on orderDetails.orderID = orders.orderID

Order Details by Order

Order ID Customer ID Order Date Product ID Quantity Order Details Date
112024-03-03 15:00:33112024-03-02 08:22:55
212024-03-01 22:11:11
322024-03-01 05:55:45
422024-03-02 14:30:13532024-03-02 14:32:39
532024-03-03 11:21:5213672024-03-03 11:10:54
532024-03-03 11:21:5227442024-03-03 11:10:54
532024-03-03 11:21:52342024-03-03 11:12:13
532024-03-03 11:21:52482024-03-03 11:12:13
532024-03-03 11:21:525432024-03-02 11:13:42
532024-03-03 11:21:526772024-03-16 12:15:30
832024-03-16 12:20:32