codisinmyvines

ss

Sep 21st, 2021
747
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE availability_details(
  2.     num_warehouse INT NOT NULL PRIMARY KEY CHECK ( num_warehouse>0 ),
  3.     id_detail INT NOT NULL CHECK ( id_detail>0 ),
  4.     unit_detail VARCHAR(3) NOT NULL DEFAULT 'шт',
  5.     quantity_in_warehouse INT NOT NULL CHECK ( quantity_in_warehouse>=0 ),
  6.     date_last_oper DATE NOT NULL
  7. );
  8. CREATE TABLE details(
  9.     id_detail INT NOT NULL UNIQUE CHECK ( id_detail>0 ),
  10.     type_of_detail TEXT NOT NULL,
  11.     name_of_detail TEXT NOT NULL,
  12.     unit_detail VARCHAR(3) NOT NULL DEFAULT 'шт',
  13.     price_unit_detail DECIMAL NOT NULL CHECK ( price_unit_detail>0 )
  14. );
  15. CREATE TABLE shipment_accounting(
  16.     num_warehouse INT NOT NULL CHECK ( num_warehouse>0 ),
  17.     num_of_ship_doc INT NOT NULL CHECK ( num_of_ship_doc>0 ),
  18.     id_customer INT NOT NULL CHECK ( id_customer>0 ),
  19.     id_ready_detail INT NOT NULL CHECK ( id_ready_detail>0 ),
  20.     unit_detail VARCHAR(3) NOT NULL DEFAULT 'шт',
  21.     quantity INT NOT NULL CHECK ( quantity>=0 ),
  22.     date_of_ship_acc DATE NOT NULL,
  23.     CONSTRAINT fkd_num_ware_house FOREIGN KEY(num_warehouse)
  24.         REFERENCES availability_details(num_warehouse) ON DELETE CASCADE,
  25.     CONSTRAINT fku_num_ware_house FOREIGN KEY(num_warehouse)
  26.         REFERENCES availability_details(num_warehouse) ON UPDATE CASCADE
  27. );
RAW Paste Data