create table if not exists users (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
chat_id INTEGER UNIQUE,
username_tg TEXT UNIQUE,
surname TEXT,
name TEXT,
patronymic TEXT,
class_digit INTEGER,
class_letter TEXT,
year_of_birth INTEGER,
watch_right INTEGER,
rent_right INTEGER,
release_right INTEGER,
order_right INTEGER,
add_right INTEGER,
remove_right INTEGER,
useradd_right INTEGER,
userdelete_right INTEGER,
adminadd_right INTEGER,
adddelete_right INTEGER,
glavadmin INTEGER
)
create table if not exists items_tag (
id INTEGER,
tag INTEGER,
FOREIGN KEY (id) REFERENCES items(id),
FOREIGN KEY (tag) REFERENCES tags(id))
create table if not exists tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
tag TEXT)
create table if not exists items (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
parent_id INTEGER,
description TEXT,
name TEXT,
model TEXT,
tags integer,
FOREIGN KEY(parent_id) REFERENCES items (id),
FOREIGN KEY(tags) REFERENCES tag_table (tag))
create table if not exists real_items (
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
item_id INTEGER,
count INTEGER,
place TEXT,
state TEXT,
importance INTEGER,
respman_id INTEGER,
FOREIGN KEY(item_id) REFERENCES items (id),
FOREIGN KEY(respman_id) REFERENCES users (id))