. Казакова. В«Основи мови TransactSQLВ» - ПГУ, 2010р.
. Електронний довідник по Transact SQL
# "justify"> Додаток А
ПРОГРАМА СТВОРЕННЯ БАЗИ ДАНИХ
CREATE DATABASE GAI
-ON PRIMARY
- (NAME = GAI, FILENAME = 'C: GAI.MDF', SIZE = 100MB, MAXSIZE = 150, FILEGROWTH = 20)
-LOG ON
- (NAME = GAI_LOG, FILENAME = 'C: GAI.LDF', SIZE = 100MB, MAXSIZE = 150, FILEGROWTH = 20)
-USE GAITABLE FIRM
(_CODE INT PRIMARY KEY CHECK (FIRM_CODE <9999 AND FIRM_CODE> 0000), _NAME CHAR (30) NOT NULL,
) TABLE COUNTRY
(_CODE INT PRIMARY KEY CHECK (COUNTRY_CODE <9999 AND COUNTRY_CODE> 0000), _NAME CHAR (30) NOT NULL,
) TABLE AM_MARK
(_CODE INT PRIMARY KEY CHECK (MARK_CODE> 0000 AND MARK_CODE <9999), _NAME CHAR (30) NOT NULL, _CODE INT NOT NULL CHECK (FIRM_CODE <9999 AND FIRM_CODE> 0000) , _CODE INT NOT NULL CHECK (COUNTRY_CODE> 0000 AND COUNTRY_CODE <9999), KEY (FIRM_CODE) REFERENCES FIRM (FIRM_CODE), KEY (COUNTRY_CODE) REFERENCES COUNTRY (COUNTRY_CODE),
) TABLE DRIVERS
(_CODE INT PRIMARY KEY CHECK (DRIVER_CODE> 0000 AND DRIVER_CODE <9999), _FIO CHAR (30) NOT NULL, _BIRTHDATE DATE NOT NULL, _ADRESS CHAR (30) NOT NULL, _PASSPORT INT NOT NULL, _RULES CHAR (12) NOT NULL, _RULES_DATE DATE NOT NULL, _CATEGORY CHAR (1) NOT NULL,
) TABLE AM
(_CODE INT PRIMARY KEY CHECK (AM_CODE <9999 AND AM_CODE> 0000), _DRIVER_CODE INT NOT NULL, _MARK_CODE INT NOT NULL, KEY (AM_DRIVER_CODE) REFERENCES DRIVERS (DRIVER_CODE), KEY (AM_MARK_CODE) REFERENCES AM_MARK (MARK_CODE), _REG_NUMBER CHAR (8) NOT NULL, _BODY_NUMBER INT NOT NULL, _ENGINE_NUMBER INT NOT NULL, _TECHPASSPORT_NUMBER INT NOT NULL, _BIRTHDATE DATE NOT NULL, _REGISTRATION_DATE DATE NOT NULL, _COLOR CHAR (7) NOT NULL,
) TABLE JACKED_CARS
(_CODE INT PRIMARY KEY CHECK (JC_CODE> 0 AND JC_CODE <9999), _JACKDATE DATE NOT NULL, _REPORT_DATE DATE NOT NULL, _AM_CODE INT NOT NULL, KEY (JC_AM_CODE) REFERENCES AM (AM_CODE) , _DRIVER_CODE INT NOT NULL, KEY (JC_DRIVER_CODE) REFERENCES DRIVERS (DRIVER_CODE), _ADDITIONAL CHAR (100), _FOUND BIT, _FOUND_DATE DATE,
)
Додаток Б
ДІАГРАМА БАЗИ ДАНИХ
В
Ріс.10.Діаграмма БД
Додаток В
ПРОГРАМА ВВЕДЕННЯ ТЕСТОВИХ ДАНИХ
INSERT INTO AM_MARK VALUES (1, 'LADA', 1, 1);
INSERT INTO AM_MARK VALUES (2, 'VW', 2, 2); INTO AM_MARK VALUES (3, &...