相关疑难解决方法(0)

为科学数据设计。具有数百列的数据表或具有通用值列和数百行 (EAV) 的数据表?

我正在尝试改进我最近开始工作的生物医学科学实验室的数据存储。现有的工作流程非常糟糕,涉及许多不同格式的 Excel 工作表,所有这些工作表都通过复制粘贴和错误宏的过程进行聚合。

我的目的是创建一个简单的 python 脚本,它将实验的所有数据聚合到 SQLite 数据库中,然后生成必要的 CSV/XLSX 输出。

我的问题是,对于我们实验的单次试验,我们最终在大约 10 个不同的时间点记录了大约 100 个变量。我最初的冲动是创建一个valuevariable表:

CREATE TABLE value (val_id INTEGER PRIMARY KEY, 
                    value TEXT, 
                    var_id INTEGER,
                    event_id INTEGER,
                    exp_id INTEGER,
                    FOREIGN KEY (var_id) REFERENCES variable(var_id),
                    FOREIGN KEY (event_id) REFERENCES event(event_id),
                    FOREIGN KEY (exp_id) REFERENCES experiemnt(exp_id)
);

CREATE TABLE variable (var_id INTEGER PRIMARY KEY,
                      var_name TEXT,
                       var_type TEXT
);

value:
val_id | value | var_id | ...
0      | 10    | 0
1      | "ROSC"| 5

variable: …
Run Code Online (Sandbox Code Playgroud)

schema database-design eav

5
推荐指数
1
解决办法
890
查看次数

Best practise for polymorphic associations in MySQL

I have a MySQL database with 3 tables holding the main classes of data:

 companies (company_id)
 persons (person_id, company_id) 
 loans (loan_id, company_id) 
Run Code Online (Sandbox Code Playgroud)

Both a 'loan' and a 'person' belong to a company. A company can have loans and a company can have people (such as directors, employees etc.)

There are several scenarios where other data can belong to either a company, a person or a loan, such as 'notes'. For example a user can add a 'note' specific to either …

mysql inheritance polymorphic-associations

4
推荐指数
1
解决办法
7754
查看次数