// Use DBML to define your database structure // Docs: https://dbml.dbdiagram.io/docs Table sheeps [note: 'Таблиця вісників'] { id integer [primary key] group_id integer [note: 'ID групи'] name text [note: 'Імʼя вісника'] icon text [note: 'Піктограмка вісника'] uuid text [note: 'Код доступа'] appointment text [default: 'lamb', note: 'Вид призначення'] can_view_stand integer [default: 0, note: 'Доступ до перегляду графіку стендів'] can_view_schedule integer [default: 0, note: 'Доступ до перегляду графіку зібрань'] can_view_territory integer [default: 0, note: 'Доступ до перегляду особистих та групових територій'] } Table administrators [note: 'Таблиця адміністраторів'] { id integer [primary key] sheep_id integer [note: 'ID вісника'] uuid text [note: 'Код доступа'] } Table moderators [note: 'Таблиця модераторів'] { id integer [primary key] sheep_id integer [note: 'ID вісника'] uuid text [note: 'Код доступа'] can_add_sheeps integer [default: 0, note: 'Доступ до додавання вісників'] can_add_territory integer [default: 0, note: 'Доступ до створення територій'] can_manager_territory integer [default: 0, note: 'Доступ до призначання територій'] can_add_stand integer [default: 0, note: 'Доступ до створення стендів'] can_manager_stand integer [default: 0, note: 'Доступ до редагування графіку стендів'] can_add_schedule integer [default: 0, note: 'Доступ до створення графіку зібрань'] } Table groups [note: 'Таблиця теократичних груп'] { id integer [primary key] group_number integer [note: 'Номер групи'] share_hash text [note: 'Код доступа для посилання спільного доступу до групових території'] } Table subscription [note: 'Таблиця токенів вісників для повідомлень'] { id integer [primary key] sheep_id integer [note: 'ID вісника'] token text [note: 'Токен пристрою'] } Table house [note: 'Таблиця багатоповерхових будинків'] { id integer [primary key] group_id integer [note: 'ID групи'] title text [note: 'Вулиця будинку'] number text [note: 'Номер будинку'] points text [default: '[]', note: 'Масив точок будинку OSM'] points_number text [default: '[]', note: 'Масив точок будинку OSM'] geo text [default: '[]', note: 'Точка будинку на мапі'] osm_id text [default: '[]', note: 'Список ID будинків в БД OSM'] settlement text [note: 'Місто роздашування'] description text [note: 'Коментар до будинку'] created_at timestamp [note: 'Дата створення будинку'] updated_at timestamp [note: 'Дата зміни будинку'] } Table entrance [note: 'Таблиця підїздів багатоповерхових будинків'] { id integer [primary key] house_id integer [note: 'ID багатоповерхового будинку'] entrance_number integer [note: 'Номер підїзду'] title text [note: 'Назва підїзду'] points text [default: '[]', note: 'Масив точок підїзду OSM'] points_number text [default: '[]', note: 'Масив точок підїзду OSM'] floors_quantity text [note: 'Кількість поверхів в підїзді'] apartments_quantity text [note: 'Кількість квартир в підїзді'] description text [note: 'Коментар до підїзду'] created_at timestamp [note: 'Дата створення підїзду'] updated_at timestamp [note: 'Дата зміни підїзду'] } Table entrance_history [note: 'Таблиця історії вісників які опрацьовували багатоповерхові будинки'] { id integer [primary key] entrance_id integer [note: 'ID підїзду'] name text [note: 'Хто опрацовував (імʼя)'] date_start timestamp [note: 'Початок опрацювання'] date_end timestamp [note: 'Кінець опрацювання'] group_id integer [note: 'Група яка опрацювувала'] sheep_id text [note: 'ID вісника що зробив зміни'] working integer [default: 0, note: 'Статус опрацювання'] } Table apartments [note: 'Таблиця квартир'] { id integer [primary key] entrance_id integer [note: 'ID підїзду'] apartment_number integer [note: 'Номер квартири'] title text [note: 'Назва квартири'] floors_number integer [note: 'Номер поверху'] status integer [note: 'Статус квартири'] description text [note: 'Коментар до квартири'] sheep_id text [note: 'ID вісника що зробив зміни'] updated_at timestamp [note: 'Дата зміни історії квартири'] } Table apartments_history [note: 'Таблиця історії опрацьовування квартир'] { id integer [primary key] sheep_id text [note: 'ID вісника що зробив зміни'] apartments_id integer [note: 'ID квартири'] status integer [note: 'Статус квартири'] description text [note: 'Коментар до квартири'] created_at timestamp [note: 'Дата зміни історії квартири'] } Table homestead [note: 'Таблиця житлових районів'] { id integer [primary key] group_id integer [note: 'ID групи'] title text [note: 'Житловий район'] number text [note: 'Номер житловогу району'] points text [default: '[]', note: 'Масив точок житловогу району OSM'] point_icons text [default: '[]', note: 'Масив точок піктограм житловогу району'] geo text [default: '[]', note: 'Точка житловогу району на мапі'] osm_id text [default: '[]', note: 'Список ID житловоих районів в БД OSM'] settlement text [note: 'Місто роздашування'] description text [note: 'Коментар до житловогу району'] created_at timestamp [note: 'Дата створення житловогу району'] updated_at timestamp [note: 'Дата зміни житловогу району'] } Table homestead_history [note: 'Таблиця історії вісників які опрацьовували житлові райони'] { id integer [primary key] homestead_id integer [note: 'ID підїзду'] name text [note: 'Хто опрацовував (імʼя)'] date_start timestamp [note: 'Початок опрацювання'] date_end timestamp [note: 'Кінець опрацювання'] group_id integer [note: 'Група яка опрацювувала'] sheep_id text [note: 'ID вісника що зробив зміни'] working integer [default: 0, note: 'Статус опрацювання'] } Table meetings_schedule [note: 'Таблиця розкладу зібрань'] { id integer [primary key] date timestamp [note: 'Дата зібрання'] type integer [note: 'Тип зібрання'] name text [note: 'Імʼя вісника що має завдання'] sheep_id text [note: 'ID вісника що має завдання'] title text [note: 'Номер пісні або назва промови'] number text [note: 'Номер пункту графіка'] } Table stand_list [note: 'Таблиця місць розташування стенду та його налаштування'] { id integer [primary key] title text [note: 'Назва місця розташування стенду'] hour_start integer [default: 10, note: 'Година початку служіння'] hour_end integer [default: 16, note: 'Година закінчення служіння'] quantity_sheep integer [default: 2, note: 'Кількість вісників, що можуть стояти одночасно'] week_days text [default: '[0, 1, 2, 3, 4, 5, 6]', note: 'Дні тижня, на яких стоїть стенд'] } Table stand_schedule [note: 'Таблиця записів служіння зі стендом'] { id integer [primary key] stand integer [note: 'ID стенду'] date timestamp [note: 'Дата служіння зі стендом'] hour integer [note: 'Година запису'] sheep_id text [note: 'ID вісника'] number_sheep text [note: 'Номер вісника, що одночасно стоїть'] updated_at timestamp [note: 'Дата зміни запису'] } Ref: sheeps.id - administrators.sheep_id // one-to-one Ref: sheeps.id - moderators.sheep_id // one-to-one Ref: sheeps.id < apartments_history.sheep_id // one-to-many Ref: sheeps.id < apartments.sheep_id // one-to-many Ref: sheeps.id < subscription.sheep_id // one-to-many Ref: sheeps.id < homestead_history.sheep_id // one-to-many Ref: sheeps.id < entrance_history.sheep_id // one-to-many Ref: sheeps.id < meetings_schedule.sheep_id // one-to-many Ref: sheeps.id < stand_schedule.sheep_id // one-to-many Ref: groups.group_number < sheeps.group_id // one-to-many Ref: groups.group_number < house.group_id // one-to-many Ref: groups.group_number < homestead.group_id // one-to-many Ref: house.id < entrance.house_id // one-to-many Ref: homestead.id < homestead_history.homestead_id // one-to-many Ref: entrance.id < entrance_history.entrance_id // one-to-many Ref: entrance.id < apartments.entrance_id // one-to-many Ref: apartments.id < apartments_history.apartments_id // one-to-many Ref: stand_list.id < stand_schedule.stand // one-to-many