Skip to content

Core Tables

This page provides detailed documentation for all tables in the Convexity database schema.

Core Tables

network_metadata

Single row per database containing network-level information.

ColumnTypeRequiredDescription
nameTEXTYesNetwork name
descriptionTEXTNoNetwork description
time_startDATETIMEYesStart time of simulation period
time_endDATETIMEYesEnd time of simulation period
time_intervalTEXTYesTime resolution (ISO 8601 format, e.g., "PT1H" for hourly)
lockedBOOLEANNoPrevents accidental edits when True
created_atDATETIMENoTimestamp when network was created
updated_atDATETIMENoTimestamp of last update

network_time_periods

Optimized time period storage using start timestamp and interval.

ColumnTypeRequiredDescription
period_countINTEGERYesTotal number of time periods (e.g., 8760 for hourly year)
start_timestampINTEGERYesUnix timestamp of first period
interval_secondsINTEGERYesSeconds between periods (e.g., 3600 for hourly)

Note: Timestamps are computed on-the-fly rather than stored for each period, saving massive space for large datasets.

carriers

Energy carrier types (electricity, gas, heat, hydrogen, etc.).

ColumnTypeRequiredDescription
idINTEGER-Primary key (auto-increment)
nameTEXTYesCarrier name (unique)
co2_emissionsREALNoCO2 emissions factor (tonnes/MWh)
colorTEXTNoHex color for visualization
nice_nameTEXTNoDisplay-friendly name
max_growthREALNoMaximum absolute growth (MW)
max_relative_growthREALNoMaximum relative growth (per unit)
curtailableBOOLEANNoWhether carrier can be curtailed

scenarios

Alternative scenarios for what-if analysis and stochastic optimization.

ColumnTypeRequiredDescription
idINTEGER-Primary key (auto-increment)
nameTEXTYesScenario name (unique)
descriptionTEXTNoScenario description
probabilityREALNoProbability for stochastic optimization (0-1, NULL for deterministic)
is_system_scenarioBOOLEANNoTrue for system-reserved scenarios (e.g., "Actual")
system_purposeTEXTNoPurpose of system scenario (e.g., "actual")

Sparse override architecture: Scenarios only store attribute values that differ from the base network, making them memory-efficient.

components

Unified table for all network components (BUS, GENERATOR, LOAD, LINE, LINK, STORAGE_UNIT, STORE, etc.).

ColumnTypeRequiredDescription
idINTEGER-Primary key (auto-increment)
component_typeTEXTYesComponent type: BUS, GENERATOR, LOAD, LINE, LINK, STORAGE_UNIT, STORE, UNMET_LOAD, CONSTRAINT, TRANSFORMER, SHUNT_IMPEDANCE
nameTEXTYesComponent name (unique across all types)
latitudeREALNoGeographic latitude for visualization
longitudeREALNoGeographic longitude for visualization
geometryTEXTNoGeoJSON geometry (Point, LineString, Polygon)
carrier_idINTEGERNoForeign key to carriers table
bus_idINTEGERNoSingle bus connection (for generators, loads, storage units)
bus0_idINTEGERNoOrigin bus for lines/links
bus1_idINTEGERNoDestination bus for lines/links

Design note: All component types share this table. The component_type field determines which attributes are valid, enforced by the validation system.

component_attributes

Unified table for all component attributes (both static and time series).

ColumnTypeRequiredDescription
idINTEGER-Primary key (auto-increment)
component_idINTEGERYesForeign key to components table
attribute_nameTEXTYesName of the attribute (e.g., "p_nom", "marginal_cost")
scenario_idINTEGERNoScenario ID (NULL = base network)
storage_typeTEXTYes"static" or "timeseries"
static_valueTEXTNoJSON-encoded value for static attributes
timeseries_dataBLOBNoBinary f32 array for time series attributes
data_typeTEXTYesData type: "float", "boolean", "string", "int"
unitTEXTNoPhysical unit (MW, MWh, EUR/MWh, etc.)
is_inputBOOLEANNoTrue for inputs, False for outputs

Storage strategy:

  • Static values stored as JSON strings (handles all data types)
  • Time series stored as raw binary f32 arrays (extremely fast, no compression overhead)
  • Exactly one of static_value or timeseries_data must be set

attribute_validation_rules

PyPSA attribute definitions with validation constraints (167+ attributes across all component types).

ColumnTypeRequiredDescription
idINTEGER-Primary key
component_typeTEXTYesComponent type this rule applies to
attribute_nameTEXTYesAttribute name (unique per component type)
display_nameTEXTNoUser-friendly display name
data_typeTEXTYesData type: "float", "boolean", "string", "int"
unitTEXTNoPhysical unit
default_valueTEXTNoDefault value if not set
allowed_storage_typesTEXTYes"static", "timeseries", or "static_or_timeseries"
is_requiredBOOLEANNoWhether attribute must be set
is_inputBOOLEANNoTrue for input attributes, False for outputs
min_valueREALNoMinimum allowed value for numeric types
max_valueREALNoMaximum allowed value for numeric types
allowed_valuesTEXTNoJSON array of allowed values for string types
group_nameTEXTNoGrouping for UI organization

Data Storage Tables

network_data_store

Generic key-value storage for arbitrary network-level data (configuration, scripts, custom data).

ColumnTypeRequiredDescription
idINTEGER-Primary key
categoryTEXTYesData category (config, results, statistics, scripts)
nameTEXTYesData item name (unique within category)
data_formatTEXTNoFormat: json, csv, binary, text, yaml, toml
dataBLOBYesActual data content
metadataTEXTNoJSON metadata about the data
checksumTEXTNoData integrity checksum

network_solve_results

Optimization solver results per scenario.

ColumnTypeRequiredDescription
idINTEGER-Primary key
scenario_idINTEGERNoScenario ID (NULL = base network)
solved_atDATETIMENoWhen optimization completed
solver_nameTEXTYesSolver used (highs, gurobi, etc.)
solve_typeTEXTYesType of optimization (lopf, pf, etc.)
solve_statusTEXTYesSolver status (optimal, infeasible, etc.)
objective_valueREALNoObjective function value
solve_time_secondsREALNoComputation time
results_jsonTEXTYesFull results as JSON
metadata_jsonTEXTNoAdditional solver metadata

network_solve_results_by_year

Year-specific results for capacity expansion models.

ColumnTypeRequiredDescription
idINTEGER-Primary key
scenario_idINTEGERNoScenario ID (NULL = base network)
yearINTEGERYesInvestment period year
results_jsonTEXTYesResults for this year as JSON
metadata_jsonTEXTNoAdditional metadata

Documentation Tables

network_notes

Network-level documentation, todos, and warnings.

ColumnTypeRequiredDescription
idINTEGER-Primary key
titleTEXTYesNote title
contentTEXTNoNote content (markdown supported)
tagsTEXTNoJSON array of tags
note_typeTEXTNoType: note, todo, warning, info, doc
priorityINTEGERNoPriority level (for sorting)

component_notes

Component-specific documentation.

ColumnTypeRequiredDescription
idINTEGER-Primary key
component_idINTEGERYesForeign key to components table
titleTEXTYesNote title
contentTEXTNoNote content (markdown supported)
tagsTEXTNoJSON array of tags
note_typeTEXTNoType: note, todo, warning, info, doc
priorityINTEGERNoPriority level

System Tables

system_metadata

System-level configuration and version tracking.

ColumnTypeRequiredDescription
idINTEGER-Primary key
keyTEXTYesConfiguration key (unique)
valueTEXTYesConfiguration value
descriptionTEXTNoDescription of this setting

Standard keys:

  • schema_version: Database schema version
  • validation_rules_version: Validation rules version
  • validation_rules_count: Total number of validation rules

network_config

Network-level configuration parameters with scenario support.

ColumnTypeRequiredDescription
idINTEGER-Primary key
scenario_idINTEGERNoScenario ID (NULL = network defaults)
param_nameTEXTYesParameter name
param_typeTEXTYesType: boolean, real, integer, string, json
param_valueTEXTYesParameter value
param_descriptionTEXTNoParameter description

attribute_scenario_cache

Performance optimization table for quick scenario counting.

ColumnTypeRequiredDescription
component_idINTEGERYesComponent ID (part of composite PK)
attribute_nameTEXTYesAttribute name (part of composite PK)
scenario_countINTEGERYesNumber of scenarios with values
has_base_valueBOOLEANYesTrue if base network has value
has_scenario_valuesBOOLEANYesTrue if any scenarios have values
scenario_detailsTEXTNoJSON array of scenario details

Purpose: Maintained by application code for instant UI updates without querying all scenarios.

© Copyright 2025 Bayesian Energy