首页 \ 问答 \ 使用相同表格的不同项目的特定配置(Specific configurations for different items using same table)

使用相同表格的不同项目的特定配置(Specific configurations for different items using same table)

所以我们有一个ITEMTVLCDPROJECTOR

我们有TVLCDPROJECTOR DAOService object ,它们也是ITEM对象。 这意味着这些表都extendsITEM表。

您可以通过UI和API服务访问这些项目。

现在,我需要将与API无关的特定UI配置放在一起。 让我们说我需要在UI中为每个项目配置显示或不显示项目的图像,让我们称之为showImageFlag 。 可以从Item的UI修改此值,这是一个复选框。

我一直在考虑几个选项:

  1. SHOW_IMAGE_FLAG列添加到ITEM表中,它是DAO和服务对象。 在服务对象上放置一个@JSonIgnore标志,以便在API端忽略它,但我们可以在UI中正常使用它。 -------我对这种方法的关注是,将来我们可能需要更多配置这些项目,或者除了tvlcdprojector之外的其他项目。 因此,这将始终促使我们向表中添加新列。 另一个问题是我们可能正在迁移所有形式的ui以使用REST API,因此我们将不得不对该JsonIgnored属性执行某些操作。

  2. ITEM_CONFIG (id, item_id, configuration, value)FK编辑到ITEMid使用键/值方法来保存与特定项目相关的N配置。 因此,在每个Web控制器上,我将传递一个ItemConfig对象,其中包含与所请求的ITEM相关的所有配置。 --------我对这个问题的关注是,我应该如何将其映射到表单(使用spring mvc )以及在UI上配置更改时应该如何保持。

请随意发表评论并为此建议任何新选项。


So we have an ITEM, TV, LCD and PROJECTOR.

We have DAO and Service object for TV, LCD and PROJECTOR that also are ITEM objects. Meaning that those tables all extends the ITEM table.

You can access these items through an UI and an API service.

Right now, I am in the need to put specific UI configurations that are not related at all with the API. Lets say that I need in the UI a configuration for each item to display or not display an image of the item on it, lets call it showImageFlag. This value can be modified from the Item's UI, this is a checkbox.

I've been thinking about a few options here:

  1. Add a column SHOW_IMAGE_FLAG to the ITEM table and it's DAO and service object. On the service object put a @JSonIgnore flag so it is ignored on the API side, but we can use it normally in the UI. ------- My concern with this approach is that in the future we might need more configuration for these items or maybe others than tv, lcd and projector. So this will always will push us to add a new column to the table. Another concern is that we might be migrating all form post ui to use the REST API, so we are going to have to do something about that JsonIgnored property.

  2. A ITEM_CONFIG (id, item_id, configuration, value) table FKed to the ITEM.id with a key/value approach to save N configuration related to specific items. So on every web controller I will be passing a ItemConfig object with all configurations related to the requested ITEM. -------- My concern with this one, is how should I map this to the form (using spring mvc) and how should I persist when the configuration changes on the UI.

Please free to comment and suggest any new option for this.


原文:https://stackoverflow.com/questions/23549353
更新时间:2022-10-06 10:10

最满意答案

我不知道这对你的问题是否可行,但如果你能,我真的会尝试在代码中开发它。

我在过去对一个大项目有一个类似的问题,需要将15年的生产数据导入新的模式(在SQL Server 2005中。)System.Data.SqlClient.SqlBulkCopy是迄今为止最快的选择。

如果你这样做,我建议一次大量插入大约1 GB的插件,然后手动调用.NET GC以释放内存中的表。 我不得不做这两件事而不会遇到内存错误(不过32位系统)。

编辑 - 我的解决方案的伪代码是这样的:

Table dataToInsert = new Table();
var sqlCommand = new SqlCommand("select * from old database");
DataReader dataFromOldSystem = sqlCommand.ExecuteReader();
foreach (DataRow oldRow in dataFromOldSystem.Tables[0])
{
// I had to modify/transpose the row from the old table in some way
DataRow newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(2));
dataToInsert.AddRow(newRow);

newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(3));
dataToInsert.AddRow(newRow);

newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(4));
dataToInsert.AddRow(newRow);

// check if the number of rows is over some magic number that is below the memory limit
// you can check the private bytes in use by your app to help guess this number
if (dataToInsert.Rows.Count > 1000000)
{
SqlBulkCopy bulkCopier = new BulkCopy(blah);
bulkCopier.Execute();

dataToInsert = null;
GC.Finalize();
GC.Free;

dataToInsert = new Table();
}
}

I don't know if this is feasible for your problem, but if you can I would really try to develop this in code.

I had a similar question for a big project in the past, that needed to import 15 years worth of production data into a new schema (in SQL Server 2005.) System.Data.SqlClient.SqlBulkCopy was by far the fastest option.

If you do go this way, I suggest doing inserts in lots of roughly 1 GB at a time, then manually calling the .NET GC to free up your table in memory. I was forced to do both of these things to not run into memory errors (32 bit system, though.)

Edit - Pseudocode for my solutiong was something like:

Table dataToInsert = new Table();
var sqlCommand = new SqlCommand("select * from old database");
DataReader dataFromOldSystem = sqlCommand.ExecuteReader();
foreach (DataRow oldRow in dataFromOldSystem.Tables[0])
{
// I had to modify/transpose the row from the old table in some way
DataRow newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(2));
dataToInsert.AddRow(newRow);

newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(3));
dataToInsert.AddRow(newRow);

newRow = new DataRow(oldRow.GetInt(0), oldRow.GetDateTime(1), oldRow.GetInt(4));
dataToInsert.AddRow(newRow);

// check if the number of rows is over some magic number that is below the memory limit
// you can check the private bytes in use by your app to help guess this number
if (dataToInsert.Rows.Count > 1000000)
{
SqlBulkCopy bulkCopier = new BulkCopy(blah);
bulkCopier.Execute();

dataToInsert = null;
GC.Finalize();
GC.Free;

dataToInsert = new Table();
}
}

相关问答

更多
  • 我认为您的问题更倾向于获得更好的CPU吞吐量,从而获得更好的性能。 所以我可能会看一些类似于异步处理的东西,其中一个线程永远不会闲置,你可能必须以链表或任何其他适合你的编程模型的数据结构的形式维护一个队列。 这样做的方法是你的线程将尝试立即执行一个给定的作业,如果有任何东西阻止他们这样做,那么他们会将该作业推入队列,这些推送的项目将根据它存储的方式进行处理容器/队列中的项目。 在你的情况下,因为你已经在使用批量sql操作,所以你最好采用这种策略。 lemme知道这对你有帮助吗? I think your p ...
  • FILLFACTOR仅适用于索引页面。 但是这里的问题是,如果你有一个聚集索引(和大多数表),你的FILLFACTOR基本上也适用于你的数据,因为你的数据存在于聚集索引的叶节点内。 基本上,如果你有一个真正的只读表,FILLFACTOR设置为100的所有索引。 对于任何给定的索引结构,这将为您提供最小和最快的表格。 请注意,如果您将FILLFACTOR设置为100,以便修改将要修改的数据的索引,则您可以自行设置页面拆分和可能降低的性能。 FILLFACTOR设置过高可能会影响插入/更新操作的性能。 修改足够 ...
  • SQL Server 2008是10.x. 您可以在SQL中使用SERVERPROPERTY并查询sys.configurations SELECT PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS varchar(20)), 3) AS MajorVersion, value_in_use FROM sys.configurations WHERE name = 'clr enabled'; 编辑:添加了CAST SQL S ...
  • 使用批量插入,但在几次委托后提交,不要尝试一次发送所有10K。 尝试调查以获得最佳尺寸,这是对内存与网络旅行的折衷。 Connection connection = new getConnection(); Statement statement = connection.createStatement(); int i = 0; for (String query : queries) { statement.addBatch("insert query"); if ((i++ % 50 ...
  • 您可以以49美元的价格购买Developer Edition,这将为您提供完整的SSMS(Management Studio),分析器等工具。您可以将其安装在Express之上(您可以在同一台计算机上安装多个SQL Server实例),但是如果您只支持Express生产,那么我只需安装客户端工具,而不必担心安装SQL Server的新实例,这种实例恰好支持您在移植代码时无法实际使用的功能。 但是,您可以在解决性能问题时进行很多分析,而无需使用Profiler,也无需完整版本的SSMS。 您可以在这里下载SS ...
  • 想到几件事。 什么是主键是GUID或整数,如果它是GUID并且您聚集在那,那么SQL Server必须插入许多不同的地方而不是顺序插入。 您是数据库大小,是您的日志大小还是自动进行自动增长,请参阅调整数据库文件大小 运行探查器并查看nhibernate创建的SQL类型。 每秒1000次插入不再令人印象深刻,瓶颈可能也是硬件,确保它的大小和配置正确。 tempdb,日志和数据文件是否在同一个驱动器上? 如果是这样,请将它们移到单独的驱动器 另一个选择是重写执行这些插入的部分并批处理它们而不是单行插入 这是我从 ...
  • 如果您将所有业务逻辑拉入应用层,那么您的应用层必须靠近数据库。 制作一个快速而灵活的远程应用程序的解决方案是使用fiefdoms-and-emissaries,这样就可以消除与数据库的紧密耦合。 作为临时解决方案,您可以通过删除到数据库的往返来加速任何操作。 如果必须保存主 - 详细信息表单,则将整个操作作为单个批次发送为单个T-SQL批处理(INSERT头,SELECT @@ identity,INSERT所有详细信息)。 当然,实际上这意味着您将业务逻辑移动到T-SQL批处理中,现在数据库中的逻辑最好还 ...
  • 我不知道这对你的问题是否可行,但如果你能,我真的会尝试在代码中开发它。 我在过去对一个大项目有一个类似的问题,需要将15年的生产数据导入新的模式(在SQL Server 2005中。)System.Data.SqlClient.SqlBulkCopy是迄今为止最快的选择。 如果你这样做,我建议一次大量插入大约1 GB的插件,然后手动调用.NET GC以释放内存中的表。 我不得不做这两件事而不会遇到内存错误(不过32位系统)。 编辑 - 我的解决方案的伪代码是这样的: Table dataToInsert = ...
  • 使用2005或2000甚至版本7数据库没有问题但是我不认为你可以在装有SQL Server 2005的盒子上安装SSIS 2008,因为你很可能需要支付单独的许可证 there is no problem using a 2005 or 2000 or even a version 7 DB However I don't think you can install SSIS 2008 on a box that has SQL Server 2005 on it since you will most l ...
  • 使用TDE时,最大的开销通常是CPU资源需求。 如果您的服务器具有足够的处理能力,那么您最有可能去。 如需进一步阅读,请查看以下资源。 SQL Server优化和加密的性能影响 了解透明数据加密(TDE) 透明数据加密注意事项 我希望这会有所帮助,如果您有其他问题,请告诉我。 Basically the largest overhead when using TDE is CPU resource requirements. If your server has sufficient processing ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。