首页 > 解决方案 > 对数据库中的非结构化表格数据进行建模

问题描述

我有以下格式的数据:

在此处输入图像描述

网格可以多达一百万行和大约 10k 列。此外,可能有数千个这样的文档。我认为对这些数据进行建模的最佳方法是使用类似 Excel 的方法,使用 XML 可以得出如下结果:

<sheetData>
    <row r="1" spans="1:4" x14ac:dyDescent="0.2">
        <c r="A1" s="1" t="s">
            <v>0</v> <!-- Means Value of type String (t="s") at 
                          A1 with value found at index 0 in 
                          a sharedStrings reference document -->
        </c>
        <c r="B1" s="1"/>  <!-- Means no data at cell B1 -->
        <c r="C1" s="1"/>  <!-- Means no data at cell C1 -->
        <c r="D1" s="1"/>  <!-- Means no data at cell D1 -->
    </row>
    <row r="2" spans="1:4" x14ac:dyDescent="0.2">
        <c r="A2" s="1"/>
        <c r="B2" s="1" t="s">
            <v>1</v>
        </c>
        <c r="C2" s="1"/>
        <c r="D2" s="1"/>
    </row>
    <row r="3" spans="1:4" x14ac:dyDescent="0.2">
        <c r="A3" s="1"/>
        <c r="B3" s="1"/>
        <c r="C3" s="1" t="s">
            <v>2</v>
        </c>
        <c r="D3" s="1"/>
    </row>
    <row r="4" spans="1:4" x14ac:dyDescent="0.2">
        <c r="A4" s="1"/>
        <c r="B4" s="1"/>
        <c r="C4" s="1"/>
        <c r="D4" s="1" t="s">
            <v>3</v>
        </c>
    </row>
</sheetData>

Excel xml 中的值是对 sharedStrings 文件的引用,因此<v>1</v>可以引用字符串“Data”。

我需要允许对这些数据进行的最常见操作是:

我熟悉电子表格的 EAV 数据模型,但对于上述非结构化数据,我不确定最好的方法。我想 MongoDB 可能与 xml 存储“最相似”,因为它是一个 json 存储,但是保存这些数据的好方法是什么?

我在想的另一种可能性是将其存储在关系数据库中,例如:

- spreadsheet_id
- row
- col
- value

但是,在考虑编辑文档时,这几乎是不可能的,如果我们允许诸如“在位置 0 处插入新行”之类的操作,这实际上需要更新该电子表格的每个值(可能有十亿个) , 只是为了插入一行。

什么可能是存储它的好方法?如果有人知道,谷歌表格如何存储他们的数据?

标签: excelxmldatabase-designspreadsheet

解决方案


推荐阅读