SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- Создание таблицы CLIENTS CREATE TABLE CLIENTS ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, PLACE_OF_BIRTH VARCHAR(255) NOT NULL, DATE_OF_BIRTH DATE NOT NULL, ADDRESS VARCHAR(255), PASSPORT VARCHAR(255) UNIQUE NOT NULL ); -- Создание таблицы TARIFS CREATE TABLE TARIFS ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, COST DECIMAL(10, 2) NOT NULL ); -- Создание таблицы PRODUCT_TYPE CREATE TABLE PRODUCT_TYPE ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, BEGIN_DATE DATE NOT NULL, END_DATE DATE, TARIF_REF INT, FOREIGN KEY (TARIF_REF) REFERENCES TARIFS(ID) ); -- Создание таблицы PRODUCTS CREATE TABLE PRODUCTS ( ID INT PRIMARY KEY, PRODUCT_TYPE_ID INT NOT NULL, NAME VARCHAR(255) NOT NULL, CLIENT_REF INT NOT NULL, OPEN_DATE DATE NOT NULL, CLOSE_DATE DATE, FOREIGN KEY (PRODUCT_TYPE_ID) REFERENCES PRODUCT_TYPE(ID), FOREIGN KEY (CLIENT_REF) REFERENCES CLIENTS(ID) ); -- Создание таблицы ACCOUNTS CREATE TABLE ACCOUNTS ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, SALDO DECIMAL(10, 2) DEFAULT 0.00, CLIENT_REF INT NOT NULL, OPEN_DATE DATE NOT NULL, CLOSE_DATE DATE, PRODUCT_REF INT, ACC_NUM VARCHAR(50) UNIQUE NOT NULL, FOREIGN KEY (CLIENT_REF) REFERENCES CLIENTS(ID), FOREIGN KEY (PRODUCT_REF) REFERENCES PRODUCTS(ID) ); -- Создание таблицы RECORDS CREATE TABLE RECORDS ( ID INT PRIMARY KEY, DT BOOLEAN NOT NULL, ACC_REF INT NOT NULL, OPER_DATE DATE NOT NULL, SUM DECIMAL(10, 2) NOT NULL, FOREIGN KEY (ACC_REF) REFERENCES ACCOUNTS(ID) ); -- Создание таблицы TARIFS CREATE TABLE TARIFS ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, COST DECIMAL(10, 2) NOT NULL );

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear