开发者

How to Store User Provided Tabular Data?

I need to allow users to upload tabular data (rows and columns of data). I have no idea what this table will look like (no clue about the number of rows and columns). Without using EAV, is there a way I can just store all this data in one massive table?

If I say that 100 columns is the maxim开发者_JAVA技巧um allowed columns for this user uploaded data, then I just create a table with 100 columns. When user uploads their data, I just fit it in this massive table.

I guess the problem would also be how to store the user's column header. And trying to do so might mean I have some form of EAV anyway.

I'm specifically looking at non-EAV solutions.

Suggestions?


You could use real MySQL tables. If you know the column names when you get the data you could make up a suitable table name (make sure you make these up yourself), create the table with the necessary number of varchar columns and populate it. You'd want to quote the column names all the time of course, that way you wouldn't have to worry too much about what the columns are called. You would also want to pay attention to the sizes of the incoming columns.

You could always ask the database for the table's schema if you needed it, just talk to the information schema tables or from show columns queries.

You might want to set aside a database (or one database per client) for these user defined tables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜