.. _db_mapping_schema: DB mapping schema ================= The DB mapping schema is a close cousin of the Spine DB schema with some extra flexibility, like the ability to specify references by name rather than by numerical id. The schema defines the following item types: ``alternative``, ``scenario``, ``scenario_alternative``, ``entity_class``, ``display_mode``, ``entity_class_display_mode``, ``superclass_subclass``, ``entity``, ``entity_group``, ``entity_alternative``, ``parameter_value_list``, ``list_value``, ``parameter_type``, ``parameter_group``, ``parameter_definition``, ``parameter_value``, ``metadata``, ``entity_metadata``, ``parameter_value_metadata``, ``entity_location``. As you can see, these follow the names of some of the tables in the Spine DB schema. The following subsections provide all the details you need to know about the different item types, namely, their fields, values, and unique keys. alternative ----------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The alternative name. * - description - str, optional - The alternative description. .. list-table:: Unique keys :header-rows: 0 * - name scenario -------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The scenario name. * - description - str, optional - The scenario description. * - active - bool, optional - Not in use at the moment. .. list-table:: Unique keys :header-rows: 0 * - name scenario_alternative -------------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - scenario_name - str - The scenario name. * - alternative_name - str - The alternative name. * - rank - int - The rank - higher has precedence. .. list-table:: Unique keys :header-rows: 0 * - scenario_name, alternative_name * - scenario_name, rank entity_class ------------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The class name. * - dimension_name_list - tuple, optional - The dimension names for a multi-dimensional class. * - entity_class_byname - tuple - A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional. * - description - str, optional - The class description. * - display_icon - int, optional - An integer representing an icon within your application. * - display_order - int, optional - Not in use at the moment. * - hidden - int, optional - Not in use at the moment. * - active_by_default - bool, optional - Default activity for the entity alternatives of the class. .. list-table:: Unique keys :header-rows: 0 * - name display_mode ------------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The display mode name. * - description - str, optional - The display mode description. .. list-table:: Unique keys :header-rows: 0 * - name entity_class_display_mode ------------------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - display_mode_name - int - The display mode name. * - display_order - int - The display order. * - display_status - str - The display status; one of 'visible', 'hidden' or 'greyed_out'. * - display_font_color - str, optional - The color of the font. * - display_background_color - str, optional - The color of the background. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, display_mode_name superclass_subclass ------------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - superclass_name - str - The superclass name. * - subclass_name - str - The subclass name. .. list-table:: Unique keys :header-rows: 0 * - subclass_name entity ------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - name - str - The entity name. * - element_name_list - tuple - The element names if the entity is multi-dimensional. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - description - str, optional - The entity description. * - lat - float, optional - The latitude of entity. * - lon - float, optional - The longitude of entity. * - alt - float, optional - The altitude of entity. * - shape_name - str, optional - The name of the entity's shape. * - shape_blob - str, optional - The shape as GEOJSON string. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, name * - entity_class_name, entity_byname entity_group ------------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - group_name - str - The group entity name. * - member_name - str - The member entity name. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, group_name, member_name entity_alternative ------------------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - alternative_name - str - The alternative name. * - active - bool, optional - Whether the entity is active in the alternative - defaults to True. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, entity_byname, alternative_name parameter_value_list -------------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The parameter value list name. .. list-table:: Unique keys :header-rows: 0 * - name list_value ---------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - parameter_value_list_name - str - The parameter value list name. * - value - bytes - The value's database representation. * - type - str, optional - The value's type. * - parsed_value - ParameterValue, optional - The value. * - index - int, optional - The value index. .. list-table:: Unique keys :header-rows: 0 * - parameter_value_list_name, value_and_type * - parameter_value_list_name, index parameter_type -------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - parameter_definition_name - str - The parameter name. * - rank - int - The rank of the type. * - type - str - The value type. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, parameter_definition_name, type, rank parameter_group --------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The parameter group name. * - color - str - Group's color as HEX. * - priority - int - Group's priority. .. list-table:: Unique keys :header-rows: 0 * - name parameter_definition -------------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - name - str - The parameter name. * - parameter_group_name - str, optional - The name of the group of the parameter. * - parameter_type_list - tuple, optional - List of valid value types. * - default_value - bytes, optional - The default value's database representation. * - default_type - str, optional - The default value's type. * - parsed_value - ParameterValue, optional - The default value. * - parameter_value_list_name - str, optional - The parameter value list name if any. * - description - str, optional - The parameter description. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, name parameter_value --------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - parameter_definition_name - str - The parameter name. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - value - bytes - The value's database representation. * - type - str, optional - The value's type. Optional only when value is null. * - parsed_value - ParameterValue, optional - The value. * - alternative_name - str, optional - The alternative name - defaults to 'Base'. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, parameter_definition_name, entity_byname, alternative_name metadata -------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - name - str - The metadata entry name. * - value - str - The metadata entry value. .. list-table:: Unique keys :header-rows: 0 * - name, value entity_metadata --------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - metadata_name - str - The metadata entry name. * - metadata_value - str - The metadata entry value. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, entity_byname, metadata_name, metadata_value parameter_value_metadata ------------------------ .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - parameter_definition_name - str - The parameter name. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - alternative_name - str - The alternative name. * - metadata_name - str - The metadata entry name. * - metadata_value - str - The metadata entry value. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, parameter_definition_name, entity_byname, alternative_name, metadata_name, metadata_value entity_location --------------- .. list-table:: Fields and values :header-rows: 1 * - field - type - value * - entity_class_name - str - The entity class name. * - entity_byname - tuple - A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional. * - lat - float, optional - Latitude. * - lon - float, optional - Longitude. * - alt - float, optional - Altitude. * - shape_name - str, optional - Name identifying the shape. * - shape_blob - str, optional - Shape as GEOJSON feature. .. list-table:: Unique keys :header-rows: 0 * - entity_class_name, entity_byname