# Diagramme Relationnel de la Base de Données Geosector ```mermaid erDiagram %% Tables de référence (x_*) x_devises ||--o{ x_pays : "fk_devise" x_pays ||--o{ x_regions : "fk_pays" x_regions ||--o{ x_departements : "fk_region" x_regions ||--o{ entites : "fk_region" x_entites_types ||--o{ entites : "fk_type" x_departements ||--o{ x_villes : "fk_departement" %% Utilisateurs et entités entites ||--o{ users : "fk_entite" entites ||--o{ operations : "fk_entite" x_users_roles ||--o{ users : "fk_role" x_users_titres ||--o{ users : "fk_titre" %% Opérations et secteurs operations ||--o{ ope_sectors : "fk_operation" operations ||--o{ ope_users : "fk_operation" operations ||--o{ ope_users_sectors : "fk_operation" operations ||--o{ ope_pass : "fk_operation" users ||--o{ ope_users : "fk_user" users ||--o{ ope_users_sectors : "fk_user" users ||--o{ ope_pass : "fk_user" users ||--o{ ope_pass_histo : "fk_user" ope_sectors ||--o{ ope_users_sectors : "fk_sector" ope_sectors ||--o{ sectors_adresses : "fk_sector" ope_sectors ||--o{ ope_pass : "fk_sector" ope_pass ||--o{ ope_pass_histo : "fk_pass" x_types_reglements ||--o{ ope_pass : "fk_type_reglement" %% Système de chat chat_rooms ||--o{ chat_participants : "id_room" chat_rooms ||--o{ chat_messages : "fk_room" chat_rooms ||--o{ chat_listes_diffusion : "fk_room" chat_rooms ||--o{ chat_notifications : "fk_room" users ||--o{ chat_rooms : "fk_user" users ||--o{ chat_participants : "id_user" users ||--o{ chat_messages : "fk_user" users ||--o{ chat_listes_diffusion : "fk_user" users ||--o{ chat_read_messages : "fk_user" users ||--o{ chat_notifications : "fk_user" chat_messages ||--o{ chat_read_messages : "fk_message" chat_messages ||--o{ chat_notifications : "fk_message" %% Définition des entités avec leurs attributs principaux x_devises { int_unsigned id PK string code string symbole string libelle tinyint_unsigned chk_active } x_pays { int_unsigned id PK int_unsigned fk_continent FK int_unsigned fk_devise FK string libelle tinyint_unsigned chk_active } x_regions { int_unsigned id PK int_unsigned fk_pays FK string libelle tinyint_unsigned chk_active } x_departements { int_unsigned id PK string code int_unsigned fk_region FK string libelle tinyint_unsigned chk_active } x_villes { int_unsigned id PK int_unsigned fk_departement FK string libelle string cp tinyint_unsigned chk_active } entites { int_unsigned id PK string libelle int_unsigned fk_region FK int_unsigned fk_type FK tinyint_unsigned chk_demo tinyint_unsigned chk_active } users { int_unsigned id PK int_unsigned fk_entite FK int_unsigned fk_role FK int_unsigned fk_titre FK string encrypted_name string encrypt_user_name string encrypt_password tinyint_unsigned chk_active } operations { int_unsigned id PK int_unsigned fk_entite FK string libelle date date_deb date date_fin tinyint_unsigned chk_active } ope_sectors { int_unsigned id PK int_unsigned fk_operation FK string libelle tinyint_unsigned chk_active } ope_users { int_unsigned id PK int_unsigned fk_operation FK int_unsigned fk_user FK tinyint_unsigned chk_active } ope_users_sectors { int_unsigned id PK int_unsigned fk_operation FK int_unsigned fk_user FK int_unsigned fk_sector FK tinyint_unsigned chk_active } sectors_adresses { int_unsigned id PK string fk_adresse int_unsigned osm_id int_unsigned fk_sector FK string rue string cp string ville } ope_pass { int_unsigned id PK int_unsigned fk_operation FK int_unsigned fk_sector FK int_unsigned fk_user FK int_unsigned fk_type_reglement FK timestamp passed_at tinyint_unsigned chk_active } ope_pass_histo { int_unsigned id PK int_unsigned fk_pass FK int_unsigned fk_user FK } chat_rooms { int_unsigned id PK string name enum type int_unsigned fk_user FK int_unsigned fk_entite FK } chat_messages { int_unsigned id PK int_unsigned fk_room FK int_unsigned fk_user FK text content enum statut } chat_read_messages { bigint_unsigned id PK int_unsigned fk_message FK int_unsigned fk_user FK timestamp date_read } chat_notifications { bigint_unsigned id PK int_unsigned fk_user FK int_unsigned fk_message FK int_unsigned fk_room FK string type } ```