turns-00063.parquet:23042
df33e931683b38af8eaace43
turn 5/19gpt-4o-mini-2024-07-18RussianRussia605 words
degenerate_repetitionAbsentFinal dense release
USER
Сгенерируй комментари так же здесь:
-- создание категории булочек
create table categorie (
category_id serial primary key,
category_name varchar(255) not null
);
-- создание булочек
create table bun (
bun_id serial primary key,
name varchar(255) not null,
price numeric(10, 2) not null,
category_id int,
constraint fk_category
foreign key (category_id)
references categorie(category_id)
on delete set null
);
-- создание ингредиентов
create table ingredient (
ingredient_id serial primary key,
ingredient_name varchar(255) not null
);
-- создание рецептов
create table recipe (
recipe_id serial primary key,
bun_id int,
ingredient_id int,
quantity numeric(10, 2) not null,
constraint fk_bun
foreign key (bun_id)
references bun(bun_id)
on delete cascade,
constraint fk_ingredient
foreign key (ingredient_id)
references ingredient(ingredient_id)
on delete cascade,
constraint unique_bun_ingredient
unique (bun_id, ingredient_id) -- уникальность комбинации булочки и ингредиента
);
-- создание заказов
create table "order"(
order_id serial primary key,
bun_id int,
order_date timestamp not null default current_timestamp,
customer_name varchar(255) not null,
quantity int not null,
constraint fk_order_bun
foreign key (bun_id)
references bun(bun_id)
on delete cascade
);ASSISTANT
Вот SQL-код с использованием команды `comment on` для добавления комментариев к таблицам и их полям, которые описывают их назначение.
```sql
-- создание категории булочек
create table categorie (
category_id serial primary key, -- Уникальный идентификатор категории
category_name varchar(255) not null -- Название категории
);
comment on table categorie is 'Таблица Категории булочек';
comment on column categorie.category_id is 'Уникальный идентификатор категории';
comment on column categorie.category_name is 'Название категории булочек';
-- создание булочек
create table bun (
bun_id serial primary key, -- Уникальный идентификатор булочки
name varchar(255) not null, -- Название булочки
price numeric(10, 2) not null, -- Цена булочки
category_id int, -- Идентификатор категории, к которой относится булочка
constraint fk_category
foreign key (category_id)
references categorie(category_id)
on delete set null
);
comment on table bun is 'Таблица Булочек';
comment on column bun.bun_id is 'Уникальный идентификатор булочки';
comment on column bun.name is 'Название булочки';
comment on column bun.price is 'Цена булочки';
comment on column bun.category_id is 'Идентификатор категории булочки';
-- создание ингредиентов
create table ingredient (
ingredient_id serial primary key, -- Уникальный идентификатор ингредиента
ingredient_name varchar(255) not null -- Название ингредиента
);
comment on table ingredient is 'Таблица Ингредиентов';
comment on column ingredient.ingredient_id is 'Уникальный идентификатор ингредиента';
comment on column ingredient.ingredient_name is 'Название ингредиента';
-- создание рецептов
create table recipe (
recipe_id serial primary key, -- Уникальный идентификатор рецепта
bun_id int, -- Идентификатор булочки, к которой относится рецепт
ingredient_id int, -- Идентификатор ингредиента в рецепте
quantity numeric(10, 2) not null, -- Количество ингредиента
constraint fk_bun
foreign key (bun_id)
references bun(bun_id)
on delete cascade,
constraint fk_ingredient
foreign key (ingredient_id)
references ingredient(ingredient_id)
on delete cascade,
constraint unique_bun_ingredient
unique (bun_id, ingredient_id) -- уникальность комбинации булочки и ингредиента
);
comment on table recipe is 'Таблица Рецептов';
comment on column recipe.recipe_id is 'Уникальный идентификатор рецепта';
comment on column recipe.bun_id is 'Идентификатор булочки, к которой относится рецепт';
comment on column recipe.ingredient_id is 'Идентификатор ингредиента в рецепте';
comment on column recipe.quantity is 'Количество данного ингредиента в рецепте';
-- создание заказов
create table "order" (
order_id serial primary key, -- Уникальный идентификатор заказа
bun_id int, -- Идентификатор булочки, которая была заказана
order_date timestamp not null default current_timestamp, -- Дата и время заказа
customer_name varchar(255) not null, -- Имя клиента, который сделал заказ
quantity int not null, -- Количество заказанных булочек
constraint fk_order_bun
foreign key (bun_id)
references bun(bun_id)
on delete cascade
);
comment on table "order" is 'Таблица Заказов';
comment on column "order".order_id is 'Уникальный идентификатор заказа';
comment on column "order".bun_id is 'Идентификатор булочки, которая была заказана';
comment on column "order".order_date is 'Дата и время заказа';
comment on column "order".customer_name is 'Имя клиента, который сделал заказ';
comment on column "order".quantity is 'Количество заказанных булочек';
```
Теперь каждая колонка и таблица имеют соответствующие комментарии, описывающие их назначение.