简体   繁体   English

用户创建的数据存储在类似表的结构中

[英]User created data stored in a table like structure

I have an asp.net 4.0 c# application where a user is now going to be able to create a table and store data in that table. 我有一个asp.net 4.0 c#应用程序,用户现在可以在其中创建表并将数据存储在该表中。 One thing that has been decided for version 1 is once the table is created it can't be edited this is purely for making it less complicated. 对于版本1决定的一件事是,一旦创建了表,就无法对其进行编辑,这纯粹是为了使其变得不那么复杂。 It would be nice to have a solution to where the schema could be edited also. 对于在哪里也可以编辑模式有一个解决方案将是很好的。

My first thought is to have a table in the db and each row would represent each "table", one column would store the schema in xml and then a second column would store the data. 我的第一个想法是在db中有一个表,每一行代表每个“表”,一列将模式存储在xml中,然后第二列将存储数据。 When trying to pull the data I would read the xml into a datatable work with the data and then save it back out to xml in the db. 当尝试提取数据时,我会将xml读入数据表中,然后将其保存回db中的xml中。 Any thoughts suggestions or links to others trying this would be greatly appreciated! 任何想法建议或尝试此操作的其他人的链接将不胜感激!

Thanks in advance. 提前致谢。

There are many ways to do it: 有很多方法可以做到这一点:

  1. You can generate real table via "create table" sqls. 您可以通过“创建表” sqls生成真实表。 This would give you the best performance, but would be a nightmare from DB administrator point of view. 这将为您带来最佳性能,但从数据库管理员的角度来看,这将是一场噩梦。 Don't do this if you're inexperienced. 如果您没有经验,请不要这样做。

  2. Make tables: MyTable, MyColumn, MyRow and MyCell. 制作表格:MyTable,MyColumn,MyRow和MyCell。

    • MyTable would have MyTableID (primary key) and Name, MyTable将具有MyTableID(主键)和Name,
    • MyColumn would have MyColumnID (primary key), MyTableID (foreign key), Name MyColumn将具有MyColumnID(主键),MyTableID(外键),名称
    • MyRow would have MyRowID (primary key), MyTableID (foreign key) MyRow将具有MyRowID(主键),MyTableID(外键)
    • MyCell would have MyCellID (primary key), MyColumnID (foreign key), MyRowID (foreign key) and Value (big variable length string) MyCell将具有MyCellID(主键),MyColumnID(外键),MyRowID(外键)和Value(大长度可变字符串)

    This way you would at least be able to use SQL to query, search and modify your data and performance would be better than with XML (although not nearly as good as when you use "create table" SQL). 这样,您至少可以使用SQL查询,搜索和修改数据,并且性能要比XML更好(尽管不如使用“创建表” SQL时要好)。

  3. You can use NoSQL database. 您可以使用NoSQL数据库。 Many of them don't have rigid structure and can store something like JSON, so you can store practically everything in them. 其中许多没有严格的结构,可以存储JSON之类的内容,因此您几乎可以将所有内容存储在其中。 There are many downsides in this solution (such as absence of SQL and no ACID transaction integrity), but maybe it would work in your case. 此解决方案有很多缺点(例如,缺少SQL且没有ACID事务完整性),但也许可以解决您的问题。 Start with What NoSQL solutions are out there for .NET? 首先从.NET的NoSQL解决方案开始

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM