DAS_2023_1/arutunyan_dmitry_lab_3/database.sql

24 lines
868 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Создание таблицы заказов
CREATE TABLE t_order (
id INTEGER PRIMARY KEY UNIQUE NOT NULL,
status VARCHAR(255) NOT NULL
);
-- Создание таблицы товаров
CREATE TABLE t_product (
id INTEGER PRIMARY KEY UNIQUE NOT NULL,
name VARCHAR(255) NOT NULL,
price INTEGER NOT NULL,
order_id INTEGER,
FOREIGN KEY (order_id) REFERENCES t_order(id)
);
-- Добавление пустых заказов
INSERT INTO t_order (id, status)
VALUES (0, 'Принят'),
(1, 'В обработке');
-- Добавление товаров
INSERT INTO t_product (id, name, price)
VALUES (0, 'Гантели', 5000),
(1, 'Эспандер', 500),
(2, 'Тренажёр', 25990);