Skip to content

Database Schema

Mirage edited this page Nov 27, 2024 · 1 revision

Database Schema Documentation

This document provides a detailed overview of the database schema used in the project. The schema includes tables for weather data, user management, roles, permissions, sessions, and related features.

1. Weather Data Schema

WeatherStation

The WeatherStation table stores information about weather stations.

Field Type Description
Id INT Primary Key, auto-incremented.
Name VARCHAR The name of the weather station.
Latitude FLOAT Latitude of the weather station.
Longitude FLOAT Longitude of the weather station.

WeatherDatas

The WeatherDatas table stores weather data for each weather station.

Field Type Description
Id INT Primary Key, auto-incremented.
WeatherStationId INT Foreign Key to WeatherStation(Id).
Timestamp TIMESTAMP Timestamp of the weather data entry.
temperature_2m FLOAT Temperature at 2 meters above the ground.
relative_humidity_2m FLOAT Relative humidity at 2 meters above the ground.
dew_point_2m FLOAT Dew point temperature at 2 meters.
apparent_temperature FLOAT Apparent temperature (feels like).
precipitation FLOAT Total precipitation in millimeters.
rain FLOAT Rainfall in millimeters.
snowfall FLOAT Snowfall in millimeters.
weather_code INT Weather condition code.
cloud_cover FLOAT Total cloud cover percentage.
cloud_cover_low FLOAT Low-level cloud cover percentage.
cloud_cover_mid FLOAT Mid-level cloud cover percentage.
cloud_cover_high FLOAT High-level cloud cover percentage.
pressure_msl FLOAT Pressure at mean sea level in hPa.
surface_pressure FLOAT Surface pressure in hPa.
vapour_pressure_deficit FLOAT Vapour pressure deficit in hPa.
evapotranspiration FLOAT Evapotranspiration value.
wind_speed_10m FLOAT Wind speed at 10 meters.
wind_speed_20m FLOAT Wind speed at 20 meters.
wind_speed_50m FLOAT Wind speed at 50 meters.
wind_speed_100m FLOAT Wind speed at 100 meters.
wind_speed_150m FLOAT Wind speed at 150 meters.
wind_speed_200m FLOAT Wind speed at 200 meters.
wind_direction_10m FLOAT Wind direction at 10 meters.
wind_direction_20m FLOAT Wind direction at 20 meters.
wind_direction_50m FLOAT Wind direction at 50 meters.
wind_direction_100m FLOAT Wind direction at 100 meters.
wind_direction_150m FLOAT Wind direction at 150 meters.
wind_direction_200m FLOAT Wind direction at 200 meters.
wind_gusts_10m FLOAT Wind gusts at 10 meters.
temperature_20m FLOAT Temperature at 20 meters.
temperature_50m FLOAT Temperature at 50 meters.
temperature_100m FLOAT Temperature at 100 meters.
temperature_150m FLOAT Temperature at 150 meters.
temperature_200m FLOAT Temperature at 200 meters.

Foreign Key Relationship:

  • WeatherStationId references WeatherStation(Id).

City and Departement Schema Documentation

This document provides a detailed overview of the City and Departement tables used in the project.

1. City Data Schema

City

The City table stores information about cities.

Field Type Description
Id INT Primary Key, auto-incremented.
Name VARCHAR Name of the city.
Latitude FLOAT Latitude of the city.
Longitude FLOAT Longitude of the city.

2. Departement Data Schema

Departement

The Departement table stores information about French departments.

Field Type Description
Id INT Primary Key, auto-incremented.
Name VARCHAR Name of the department.
Code VARCHAR Department code (e.g., 75 for Paris).
Latitude FLOAT Latitude of the central point of the department.
Longitude FLOAT Longitude of the central point of the department.

Notes:

  • The Latitude and Longitude fields in the Departement table represent the central point of the department.
  • The Code field holds the unique code for each department, which is useful for administrative purposes.

2. User Management

users

The users table stores information about the users in the system.

Field Type Description
id BIGINT Primary Key, auto-incremented.
firstname VARCHAR First name of the user.
lastname VARCHAR Last name of the user.
email VARCHAR Email address of the user (unique).
password VARCHAR Password for the user.
manager_id BIGINT Foreign Key referencing users(id) (self-relationship).
created_at TIMESTAMP Timestamp when the user was created.
updated_at TIMESTAMP Timestamp when the user was last updated.

Foreign Key Relationship:

  • manager_id references users(id) for hierarchical user management (manager-subordinate).

roles

The roles table defines different roles that a user can have.

Field Type Description
id BIGINT Primary Key, auto-incremented.
name VARCHAR Role name (e.g., Admin, User).
guard_name VARCHAR Name of the guard for the role.
created_at TIMESTAMP Timestamp when the role was created.
updated_at TIMESTAMP Timestamp when the role was last updated.

permissions

The permissions table stores different permissions that can be granted to roles.

Field Type Description
id BIGINT Primary Key, auto-incremented.
name VARCHAR Name of the permission.
guard_name VARCHAR Name of the guard for the permission.
created_at TIMESTAMP Timestamp when the permission was created.
updated_at TIMESTAMP Timestamp when the permission was last updated.

model_has_roles

The model_has_roles table relates models (users) to roles.

Field Type Description
role_id BIGINT Foreign Key referencing roles(id).
model_type VARCHAR The type of the model (e.g., User).
model_id BIGINT Foreign Key referencing users(id).

model_has_permissions

The model_has_permissions table relates models (users) to permissions.

Field Type Description
permission_id BIGINT Foreign Key referencing permissions(id).
model_type VARCHAR The type of the model (e.g., User).
model_id BIGINT Foreign Key referencing users(id).

3. Session Management

sessions

The sessions table stores session information for users.

Field Type Description
id VARCHAR Primary Key, session ID.
user_id BIGINT Foreign Key referencing users(id).
ip_address VARCHAR IP address of the user.
user_agent TEXT User agent string (browser info).
payload TEXT Session payload data.
last_activity INT Last activity timestamp.

4. Invite Management

invites

The invites table stores information about user invitations.

Field Type Description
id BIGINT Primary Key, auto-incremented.
token VARCHAR Invitation token (unique).
expires_at TIMESTAMP Expiration date for the invite.
created_at TIMESTAMP Timestamp when the invite was created.
updated_at TIMESTAMP Timestamp when the invite was last updated.

password_reset_tokens

The password_reset_tokens table stores tokens for password resets.

Field Type Description
email VARCHAR Email address associated with the token.
token VARCHAR Password reset token.
created_at TIMESTAMP Timestamp when the reset token was created.

Conclusion

This documentation outlines the main tables and relationships for user and weather data management in the Laravel project. It also covers role-based access control and session management. invites laravel