﻿== Lab 2 schema and query results (psql, -w, pgpass only) ==
psql (PostgreSQL) 14.25

           List of relations
 Schema |    Name     | Type  |  Owner  
--------+-------------+-------+---------
 public | customers   | table | gigaide
 public | order_items | table | gigaide
 public | orders      | table | gigaide
 public | products    | table | gigaide
(4 rows)

                     Table "public.customers"
 Column |          Type          | Collation | Nullable | Default 
--------+------------------------+-----------+----------+---------
 id     | uuid                   |           | not null | 
 name   | character varying(200) |           | not null | 
 email  | character varying(255) |           | not null | 
Indexes:
    "customers_pkey" PRIMARY KEY, btree (id)
    "customers_email_unique" UNIQUE CONSTRAINT, btree (email)
Referenced by:
    TABLE "orders" CONSTRAINT "fk_orders_customer_id__id" FOREIGN KEY (customer_id) REFERENCES customers(id) ON UPDATE RESTRICT ON DELETE RESTRICT

                                Table "public.orders"
   Column    |            Type             | Collation | Nullable |      Default      
-------------+-----------------------------+-----------+----------+-------------------
 id          | uuid                        |           | not null | 
 customer_id | uuid                        |           | not null | 
 status      | character varying(20)       |           | not null | 
 created_at  | timestamp without time zone |           | not null | CURRENT_TIMESTAMP
Indexes:
    "orders_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "fk_orders_customer_id__id" FOREIGN KEY (customer_id) REFERENCES customers(id) ON UPDATE RESTRICT ON DELETE RESTRICT
Referenced by:
    TABLE "order_items" CONSTRAINT "fk_order_items_order_id__id" FOREIGN KEY (order_id) REFERENCES orders(id) ON UPDATE RESTRICT ON DELETE RESTRICT

                 Table "public.order_items"
   Column   |     Type      | Collation | Nullable | Default 
------------+---------------+-----------+----------+---------
 id         | uuid          |           | not null | 
 order_id   | uuid          |           | not null | 
 product_id | uuid          |           | not null | 
 quantity   | integer       |           | not null | 
 unit_price | numeric(12,2) |           | not null | 
Indexes:
    "order_items_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "fk_order_items_order_id__id" FOREIGN KEY (order_id) REFERENCES orders(id) ON UPDATE RESTRICT ON DELETE RESTRICT
    "fk_order_items_product_id__id" FOREIGN KEY (product_id) REFERENCES products(id) ON UPDATE RESTRICT ON DELETE RESTRICT

== Row counts ==
 customers | products | orders | order_items 
-----------+----------+--------+-------------
         1 |        2 |      1 |           3
(1 row)

== Orders with customers (the join used by the script) ==
                  id                  |  status   |       customer        |           email           |         created_at         
--------------------------------------+-----------+-----------------------+---------------------------+----------------------------
 0142b4d3-4dd6-456d-a0da-b08a33f0c52e | CONFIRMED | Ada Lovelace 4a550e7b | lab2+4a550e7b@example.com | 2026-12-01 18:31:10.666487
(1 row)

== Order lines with product names and line totals ==
               order_id               |           product            | quantity | unit_price | line_total 
--------------------------------------+------------------------------+----------+------------+------------
 0142b4d3-4dd6-456d-a0da-b08a33f0c52e | Mechanical Keyboard 4a550e7b |        2 |     129.00 |     258.00
 0142b4d3-4dd6-456d-a0da-b08a33f0c52e | Mechanical Keyboard 4a550e7b |        1 |     129.00 |     129.00
 0142b4d3-4dd6-456d-a0da-b08a33f0c52e | USB-C Hub 4a550e7b           |        1 |      59.90 |      59.90
(3 rows)
