Store spreadsheet kind of data in SQL Database

假如想象 提交于 2019-12-21 06:51:56

问题


I want to store the spreadsheet data in database, so right now i am using key/value pattern to store the same but its taking too much time to retrieve it from data base, if the data is huge. Do anyone has the best way to do the same. How Google saves their spreadsheet data?

Usually I have to show 30 to 40 columns and 10,000 rows on the web page with page size 500 or 1000 for pagination. Data is for line item with pricing.

My current database structure is as below.

Column Table Column_Id int Column_Name nvarchar(50)
Column_Type nvarchar(50)

Value Content Table criteria_id int column_id int row_id int column_contents nvarchar(100)


回答1:


A naive schema for storing a spreadsheet:

create table spreadsheet
(
id INTEGER primary key,
name TEXT UNIQUE not null
);

create table cell
(
id INTEGER primary key,
spreadsheet_id INTEGER NOT NULL REFERENCES spreadsheet(id),
row INTEGER not null,
col INTEGER not null,
content TEXT NOT NULL
);



回答2:


If you're just loading and saving it, not querying it much, I would recommend an XML field for the entire sheet, or each page, or at least each row.

My other question is, how are you querying this to populate your sheet? Are you using loops and opening separate queries for each row or column?

Your design may be suboptimal, but it actually should be performing decently for the data set you're describing, IMHO.




回答3:


Considering that Excel is widely considered to be the default tool for a database, I'm not sure there's anything about the kinds of data that is stored in spreadsheets except it's a single table and there's a limit on the number of rows.

I don't think there's enough distinction to say anything else than "It's the data that determines the structure, not the source."



来源:https://stackoverflow.com/questions/998410/store-spreadsheet-kind-of-data-in-sql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!