Changes between Initial Version and Version 1 of View2


Ignore:
Timestamp:
08/21/26 08:38:33 (26 hours ago)
Author:
235018
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • View2

    v1 v1  
     1= Complete overview of customer orders
     2
     3=== Description
     4This view provides a complete overview of customer orders by combining information about the customer, order, and products included in the order.
     5
     6The view is intended for:
     7
     8- displaying customer orders in the user interface
     9- order management
     10- customer order tracking
     11- sales reports and analytical queries
     12
     13==== Tables covered by the view:
     14
     15- Client
     16- Order
     17- Product
     18- makes_order
     19- includes
     20
     21==== SQL код
     22{{{#!sql
     23CREATE OR REPLACE VIEW vw_customer_order_overview AS
     24SELECT
     25    o.order_num,
     26    o.quantity,
     27    o.status,
     28    o.last_modified_date,
     29    o.payment_method,
     30    o.discount,
     31    c.client_id,
     32    c.first_name,
     33    c.last_name,
     34    c.email,
     35    p.code AS product_code,
     36    p.description AS product_description,
     37    p.price FROM "order" o
     38JOIN makes_order mo
     39    ON mo.order_num = o.order_num
     40JOIN client c
     41    ON c.client_id = mo.client_id
     42JOIN includes i
     43    ON i.order_num = o.order_num
     44JOIN product p
     45    ON p.code = i.code;
     46
     47}}}
     48
     49==== Logic explanation
     50**1.** The basic order information is retrieved from `order`.
     51**2.** The `makes_order` relationship connects each order with the client who made it.
     52**3.** Client information is retrieved from `client`.
     53**4.** The `includes` relationship connects orders with the products they contain.
     54**5.** Product information is retrieved from `product`.
     55**6.** The result provides customer, order, and product information in a single view.
     56**7.** An order containing multiple products can appear in multiple rows, one for each included product.
     57
     58==== Reason for view
     59This view is useful because:
     60
     61- It combines all important information about customer orders
     62- It simplifies order management queries
     63- It reduces the complexity of repeated JOIN operations
     64- It provides a consistent format for displaying order information
     65- It can be used for customer order history and sales analysis
     66
     67Without this view, every application query requiring customer, order, and product information would need to independently join client, makes_order, order, includes, and product.