1. aminiy
  2. docbase

Commits

amin  committed bd650b5

Модель

  • Participants
  • Parent commits b8eb7f5
  • Branches default

Comments (0)

Files changed (2)

File db/model.grc

Binary file modified.

File db/sql.sql

View file
 /***                            Tables and Views                            ***/
 /******************************************************************************/
 
+CREATE TABLE APPLICATION (
+    ID INTEGER NOT NULL,
+    CONTRACT_ID INTEGER NOT NULL,
+    V_DATE DATE NOT NULL,
+    NUMBER VARCHAR(10),
+    D_BEGIN DATE,
+    D_END DATE,
+    ADDRESS VARCHAR(80),
+    PERSON VARCHAR(80),
+    COTROLE VARCHAR(40),
+    B_SHIP_TIME TIMESTAMP,
+    E_SHIP_TIME TIMESTAMP,
+    DUMP_TIME INTEGER,
+    ADD_TERM VARCHAR(200));
+
+
+CREATE TABLE APPLICATION_CARGO (
+    ID INTEGER NOT NULL,
+    APPLICATION_ID INTEGER NOT NULL,
+    DEPARTURE VARCHAR(80),
+    DESTINATION VARCHAR(80),
+    CARGO VARCHAR(40),
+    WEIGHT DECIMAL(15,2),
+    DISTANCE DECIMAL(15,2),
+    HANDLING VARCHAR(40),
+    NOTE VARCHAR(40));
+
+
+CREATE TABLE CARGO (
+    ID INTEGER NOT NULL,
+    CARGO_WAYBILL_ID INTEGER NOT NULL,
+    NAME VARCHAR(80),
+    UNIT VARCHAR(10),
+    AMOUNT DECIMAL(15,2),
+    SUM_TOTAL DECIMAL(16,2),
+    DOCS VARCHAR(40),
+    METHOD VARCHAR(40),
+    CLASS VARCHAR(40),
+    GROSS DECIMAL(15,2),
+    NET DECIMAL(15,2));
+
+
+CREATE TABLE CARGO_WAYBILL (
+    ID INTEGER NOT NULL,
+    APPLICATION_ID INTEGER NOT NULL,
+    V_DATE DATE,
+    NUMBER VARCHAR(10),
+    TRUCK VARCHAR(80),
+    WAYBILL_NUM VARCHAR(10),
+    WAYBILL_DATE DATE,
+    D_DATE TIMESTAMP,
+    CLIENT VARCHAR(80),
+    SHIPPER VARCHAR(80),
+    CONSIGNEE VARCHAR(80),
+    LOADING_PLACE VARCHAR(80),
+    UNLOADING_PLACE VARCHAR(80),
+    DRIVERS VARCHAR(160));
+
+
 CREATE TABLE CLIENTS (
     ID INTEGER NOT NULL,
     NAME VARCHAR(80),
     E_MAIL VARCHAR(40));
 
 
+CREATE TABLE CONTRACT (
+    ID INTEGER NOT NULL,
+    NUMBER VARCHAR(10),
+    V_DATE DATE NOT NULL,
+    CLIENTS_ID INTEGER NOT NULL,
+    D_DATE DATE);
+
+
 CREATE TABLE MFO (
     MFO VARCHAR(5) NOT NULL,
     NAME VARCHAR(80));
 /******************************************************************************/
 
 
+ALTER TABLE APPLICATION ADD CONSTRAINT PK_APPLICATION PRIMARY KEY (ID);
+ALTER TABLE APPLICATION_CARGO ADD CONSTRAINT PK_APPLICATION_CARGO PRIMARY KEY (ID);
+ALTER TABLE CARGO ADD CONSTRAINT PK_CARGO PRIMARY KEY (ID);
+ALTER TABLE CARGO_WAYBILL ADD CONSTRAINT PK_WAYBILL PRIMARY KEY (ID);
 ALTER TABLE CLIENTS ADD CONSTRAINT PK_CLIENTS PRIMARY KEY (ID);
+ALTER TABLE CONTRACT ADD CONSTRAINT PK_CONTRACT PRIMARY KEY (ID);
 ALTER TABLE MFO ADD CONSTRAINT PK_MFO PRIMARY KEY (MFO);
 
 /******************************************************************************/
 /******************************************************************************/
 
 
+ALTER TABLE APPLICATION ADD CONSTRAINT FK_APPLICATION_1 FOREIGN KEY (CONTRACT_ID) REFERENCES CONTRACT (ID);
+ALTER TABLE APPLICATION_CARGO ADD CONSTRAINT FK_APPLICATION_CARGO_1 FOREIGN KEY (APPLICATION_ID) REFERENCES APPLICATION (ID);
+ALTER TABLE CARGO ADD CONSTRAINT FK_CARGO_1 FOREIGN KEY (CARGO_WAYBILL_ID) REFERENCES CARGO_WAYBILL (ID);
+ALTER TABLE CARGO_WAYBILL ADD CONSTRAINT FK_WAYBILL_1 FOREIGN KEY (APPLICATION_ID) REFERENCES APPLICATION (ID);
 ALTER TABLE CLIENTS ADD CONSTRAINT F_MFO FOREIGN KEY (MFO) REFERENCES MFO (MFO) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE CONTRACT ADD CONSTRAINT FK_CONTRACT_1 FOREIGN KEY (CLIENTS_ID) REFERENCES CLIENTS (ID);
 
 /******************************************************************************/
 /***                           Check constraints                            ***/