lmmentel / mendeleev

A python package for accessing various properties of elements, ions and isotopes in the periodic table of elements.
https://mendeleev.readthedocs.io
MIT License
208 stars 38 forks source link

Create metadata table for stored properties #156

Closed lmmentel closed 1 month ago

lmmentel commented 1 month ago

The main purpose of this PR is to make properties metadata available alongside actual data so it can be used and referenced.

This is achieved by adding a new model PropertyMetdata with the following columns:

class ValueOrigin(enum.Enum):
    STORED = "stored"
    COMPUTED = "computed"

class PropertyMetadata(Base):
    """Metadata for properties of elements and isotopes."""

    __tablename__ = "propertymetadata"

    id = Column(Integer, primary_key=True)
    annotations = Column(Text)
    attribute_name = Column(String, nullable=False)
    category = Column(String)
    citation_keys = Column(String)
    class_name = Column(String, nullable=False)
    column_name = Column(String, nullable=True)
    description = Column(Text, nullable=False)
    table_name = Column(String, nullable=True)
    unit = Column(String)
    value_origin = Column(Enum(ValueOrigin), nullable=False)

Here is 5 first rows from the new propertymetadata table:

sqlite> SELECT * FROM propertymetadata limit 5;
+----+------------+--------------------+------------+--------------------+------------------------+--------------+--------------------------------+-------+-------------+-------------------+
| id | table_name |    column_name     | class_name |   attribute_name   |        category        | value_origin |          description           | unit  | annotations |   citation_keys   |
+----+------------+--------------------+------------+--------------------+------------------------+--------------+--------------------------------+-------+-------------+-------------------+
| 1  | elements   | abundance_crust    | Element    | abundance_crust    | abundance              | STORED       | Abundance in the Earth's crust | mg/kg |             | haynes2014crc     |
| 2  | elements   | abundance_sea      | Element    | abundance_sea      | abundance              | STORED       | Abundance in the seas          | mg/L  |             | haynes2014crc     |
| 3  | elements   | atomic_number      | Element    | atomic_number      | basic properties       | STORED       | Atomic number                  |       |             |                   |
| 4  | elements   | atomic_radius      | Element    | atomic_radius      | atomic size properties | STORED       | Atomic radius                  | pm    |             | Slater1964        |
| 5  | elements   | atomic_radius_rahm | Element    | atomic_radius_rahm | atomic size properties | STORED       | Atomic radius by Rahm et al.   | pm    |             | Rahm2016,Rahm2017 |
+----+------------+--------------------+------------+--------------------+------------------------+--------------+--------------------------------+-------+-------------+-------------------+

Related issues: