Changes between Initial Version and Version 1 of View6


Ignore:
Timestamp:
08/21/26 08:58:11 (26 hours ago)
Author:
235018
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • View6

    v1 v1  
     1= Store inventory overview
     2
     3=== Description
     4This view provides an overview of the current inventory of every store, including the products sold, their prices, available quantities, discounts, and product information.
     5
     6The view is intended for:
     7
     8- inventory management
     9- monitoring product availability
     10- store management
     11- identifying products with low stock
     12
     13==== Tables covered by the view:
     14
     15- Product
     16- Store
     17- sells
     18
     19==== SQL код
     20{{{#!sql
     21CREATE OR REPLACE VIEW vw_store_inventory AS
     22SELECT
     23    s.store_id,
     24    s.name AS store_name,
     25
     26    p.code AS product_code,
     27    p.description,
     28    p.price,
     29    p.availability,
     30    p.approx_production_time,
     31
     32    sl.quantity,
     33    sl.discount
     34
     35FROM store s
     36JOIN sells sl
     37    ON sl.store_id = s.store_id
     38JOIN product p
     39    ON p.code = sl.code;
     40
     41}}}
     42
     43==== Logic explanation
     44**1.** The `store` table provides store information.
     45
     46**2.** The `sells` relationship connects stores with the products they sell.
     47
     48**3.** The `product` table provides product details.
     49
     50**4.** The quantity and discount are retrieved from `sells`.
     51
     52**5.** Each row represents a product being sold by a particular store.
     53
     54==== Reason for view
     55This view is useful because:
     56
     57- It provides a centralized inventory overview
     58- It allows stores to monitor available products
     59- It simplifies stock-related queries
     60- It allows products and their quantities to be easily compared between stores
     61- It can be used to identify products with low availability
     62
     63Without this view, inventory queries would repeatedly need to join store, sells, and product, increasing the complexity of the application.