Changes between Initial Version and Version 1 of View1


Ignore:
Timestamp:
08/21/26 08:31:01 (27 hours ago)
Author:
235018
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • View1

    v1 v1  
     1= Complete overview of products and stores
     2
     3=== Description
     4This view provides a complete overview of the products currently being sold by each store, combining product information with store information and sales data in a single view.
     5
     6The view is intended for:
     7
     8- displaying products and stores in the user interface
     9- inventory management
     10- product availability checks
     11- analytical queries and reports
     12
     13==== Tables covered by the view:
     14
     15- Product
     16- Store
     17- sells
     18
     19==== SQL код
     20{{{#!sql
     21CREATE OR REPLACE VIEW vw_product_store_overview AS
     22SELECT
     23    p.code AS product_code,
     24    p.description,
     25    p.price,
     26    p.availability,
     27    p.weight,
     28    p.approx_production_time,
     29    s.store_id,
     30    s.name AS store_name,
     31    s.physical_address,
     32    s.rating,
     33    sl.quantity,
     34    sl.discount
     35FROM product p
     36JOIN sells sl
     37    ON sl.code = p.code
     38JOIN store s
     39   ON s.store_id = sl.store_id;
     40
     41}}}
     42
     43==== Logic explanation
     44**1.** The basic product information is retrieved from `product`.
     45**2.** The `sells` relationship connects each product with the stores selling it.
     46**3.** Store information is retrieved from `store`.
     47**4.** The current quantity and possible discount are displayed from `sells`.
     48**5.** A similar product can appear multiple times if it is sold by multiple stores.
     49
     50==== Reason for view
     51This view is useful because:
     52
     53- It centralizes product and store information in one place
     54- It simplifies inventory-related queries
     55- It reduces the need to repeatedly implement the same JOIN operations
     56- It provides a consistent format for displaying products and stores
     57- It can be used directly by the application for product listings and inventory management
     58
     59Without this view, every application query that needs both product and store information would have to independently join product, sells, and store.