Методичні вказівки до обов’язкового домашнього завдання з дисципліни «Організація баз даних та знань», страница 4

   ALTER TABLE GROUPS ADD CONSTRAINT PK_GROUPS

      PRIMARY KEY (GROUP_ID);

   ALTER TABLE GROUPS ADD CONSTRAINT FK_GROUPS

      FOREIGN KEY (UGROUP_ID) REFERENCES GROUPS (GROUP_ID)

      ON UPDATE CASCADE;

   CREATE TRIGGER GROUPS_BI FOR GROUPS

      ACTIVE BEFORE INSERT POSITION 0 AS BEGIN

        IF ((NEW.GROUP_ID IS NULL) OR (NEW.GROUP_ID <1))

        THEN     NEW.GROUP_ID = GEN_ID(GEN_GROUPS_ID,1);

        END ;

б) CREATE GENERATOR GEN_SUBSTANCE_ID;

   CREATE TABLE SUBSTANCE ( SUB_ID    D_ID NOT NULL,

        GROUP_ID  D_ID,  S_NAME    D_NOTE_50 NOT NULL );

   ALTER TABLE SUBSTANCE ADD CONSTRAINT PK_SUBSTANCE

        PRIMARY KEY (SUB_ID);

   ALTER TABLE SUBSTANCE ADD CONSTRAINT FK_SUBSTANCE

        FOREIGN KEY (GROUP_ID) REFERENCES

        GROUPS(GROUP_ID) ON UPDATE CASCADE;

   CREATE TRIGGER SUBSTANCE_BI FOR SUBSTANCE

        ACTIVE BEFORE INSERT POSITION 0 AS BEGIN

     IF ((NEW.SUB_ID IS NULL) OR (NEW.SUB_ID <1)) THEN

           NEW.SUB_ID = GEN_ID(GEN_SUBSTANCE_ID,1);

     END ;

в) CREATE TABLE NH3TD_SATUR ( SUB_ID  D_ID,

        T       D_DOUBLE_NZ,     P       D_DOUBLE_NZ,

        VSPL    D_DOUBLE_NZ,     VSPW    D_DOUBLE_NZ,

        IL      D_DOUBLE_NZ,     IW      D_DOUBLE_NZ,

        SL      D_DOUBLE_NZ,     SW      D_DOUBLE_NZ   );

   ALTER TABLE NH3TD_SATUR ADD CONSTRAINT PK_NH3TD_SATUR

        PRIMARY KEY (SUB_ID, T);

   ALTER TABLE NH3TD_SATUR ADD CONSTRAINT FK_NH3TD_SATUR

        FOREIGN KEY (SUB_ID) REFERENCES

        SUBSTANCE (SUB_ID) ON UPDATE CASCADE;

   CREATE INDEX NH3TD_SATUR_P ON NH3TD_SATUR (SUB_ID, P);

Г) CREATE TABLE NH3TD_SHW ( SUB_ID  D_ID,

         P      D_DOUBLE_NZ,     T       D_DOUBLE_NZ,

         VW      D_DOUBLE_NZ,    IW      D_DOUBLE_NZ,

         SW      D_DOUBLE_NZ);

   ALTER TABLE NH3TD_SHW ADD CONSTRAINT PK_NH3TD_SHW

         PRIMARY KEY (SUB_ID, P, T);

   ALTER TABLE NH3TD_SHW ADD CONSTRAINT FK_NH3TD_SHW

         FOREIGN KEY (SUB_ID) REFERENCES

         SUBSTANCE (SUB_ID) ON UPDATE CASCADE;

Тексти програми з коментарями.

Керуючий модуль проекту.

program pNH3td;

uses

  Forms,

  uMain in 'uMain.pas' {fmMainNH3},

  uDM in 'uDM.pas' {DM: TDataModule},

  uFmGr in 'uFmGr.pas' {fmGrSub},

  upMDForm in 'upMDForm.pas' {fmSimpleMD},

  uSearchSat in 'uSearchSat.pas' {fmCalcNH3Satur},

  uDebug in 'uDebug.pas' {fmDebug},

  uNH3vapSH in 'uNH3vapSH.pas' {fmNH3vapSH},

  uNH3Satur in 'uNH3Satur.pas' {fmNH3Satur},

  uSearchSupH in 'uSearchSupH.pas' {fmCalcNH3sh};

{$R *.res}

begin

  Application.Initialize;

  Application.CreateForm(TfmMainNH3, fmMainNH3);

  Application.CreateForm(TDM, DM);

  Application.CreateForm(TfmGrSub, fmGrSub);

  Application.CreateForm(TfmCalcNH3Satur, fmCalcNH3Satur);

  Application.CreateForm(TfmNH3vapSH, fmNH3vapSH);

  Application.CreateForm(TfmNH3Satur, fmNH3Satur);

  Application.CreateForm(TfmCalcNH3sh, fmCalcNH3sh);

  Application.Run;

end.

Головна форма.

Рисунок 2. Зовнішній вигляд головної форми

unit uMain;

//   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

//   $$    Составила Петрова И.С.,       $$

//   $$    студентки группы ИТЗТ-ХХс     $$

//   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

interface

uses Windows, Messages, SysUtils, Variants, Classes,  Graphics, Controls,

  Forms,   Dialogs,  ToolWin,  ComCtrls, ExtCtrls, Buttons,  Menus, StdCtrls;

type

  TfmMainNH3 = class(TForm)

    MainMenu1: TMainMenu;     DataBas1: TMenuItem;

    Open1: TMenuItem;         Close1: TMenuItem;

    Tables1: TMenuItem;       Search1: TMenuItem;

    GSub: TMenuItem;          ControlBar2: TControlBar;

    Caption1: TMenuItem;      ControlBar1: TControlBar;

    ToolBar1: TToolBar;       sbtOpen: TSpeedButton;

    sbtClose: TSpeedButton;   sbtSearchSt: TSpeedButton;

    VapSuperHeat: TMenuItem;  Label1: TLabel; sbtSearchSp: TSpeedButton;

    VapSaturation: TMenuItem; Caption2: TMenuItem;

    procedure Open1Click(Sender: TObject);

    procedure Close1Click(Sender: TObject);

    procedure GSubClick(Sender: TObject);

    procedure Caption1Click(Sender: TObject);

    procedure VapSuperHeatClick(Sender: TObject);