cbeauhilton / extremebiometry

Database and API for known extremes in the measurement of living things.
ISC License
0 stars 0 forks source link

Data Model #1

Open cbeauhilton opened 3 years ago

cbeauhilton commented 3 years ago

Model Example


from sqlmodel import Field, SQLModel

class MetricBase(SQLModel):
    organism: str = "homo sapiens"
    clinical_setting: str = "all"
    sample_source: str = "blood"
    metric_name: str
    units: str
    maximum_known: Optional[float]
    minimum_known: Optional[float]
    maximum_known_ref: Optional[str]
    minimum_known_ref: Optional[str]
    upper_limit_normal: Optional[float]
    lower_limit_normal: Optional[float]
    normals_ref: Optional[str}

class Metric(MetricBase, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
cbeauhilton commented 3 years ago

Data Dictionary

cbeauhilton commented 3 years ago

Data Infrastructure

Relational databases (SQLite/PostgreSQL) are probably the right answer, but a NoSQL approach may make it easier to adjust on the fly without a bunch of migrations. Making these migrations easy is probably the "real" answer. SQLModel is also very, very nice, and would be a shame to lose if we chose a NoSQL approach. Could also do what I’m doing for the ash-abstracts project and build the db from JSON, with ‘alter=true’, which kind of accomplishes both goals.

I'm fairly certain I'm going to miss a bunch of possibly essential fields for the core database. May also make sense to have a separate table for each metric? (I think I like the metric-based approach, as opposed to a hierarchical approach based on e.g. organism)