首页 \ 问答 \ 在DBMS中处理完整历史记录的最佳设计(Best design for handling complete history in a DBMS)

在DBMS中处理完整历史记录的最佳设计(Best design for handling complete history in a DBMS)

我正在开发一个带有多个实体和关系的DBMS的网站。 我希望网站的用户能够查看某些内容中已更改内容的完整历史记录,例如,何时,由谁以及字段已更改为什么。

到目前为止,我已经考虑使用链表方法,您只需持久而不是更新实体,并将ID保存到上一个实体。 但是,由于关系可能会发生变化,因此我不知道上次更新时链接实体的情况。 我的意思是关系可以改变:假设我有一个Person实体,它与另一个Person实体有连接。 如果我只保留另一个人的ID,我不知道其他人员字段是否已被更新,例如,如果另一个人例如更改了其名称字段。 请参阅下文以进一步了解情况。

另一个方法可能是顺序保存对数据库的每个更改,并简单地恢复到给定的更改,例如保存所有的sql查询。

有谁知道处理这个问题的正确方法? 提前致谢。

更新

假设我有一个名为Person的实体(见下文)。 这个人可以有很多父母和孩子。 让我们说用户可以更新现有Person中的值。 每当用户例如更新名称字段时,我想保存此更改,以便其他用户可以根据需要还原更改。 如上所述,如果我只持有父母的身份证,我不知道有这个身份证的人是否有所改变。 例如,如果父母名称已更新。

Person {
    int id;
    String name; 
    List<Person> parents;
    List<Person> children;
}

总之:我需要在更新时显示此Person实体的列表。 在这个列表中,我需要查看Persons字段确实包含的内容,以及其父母和孩子如何查看给定更改的时间。


I am developing a website with a DBMS with several entities and relationships. I want users of the website to be able to view a complete history of what has been changed in certain entites, e.g. when, by whom and what a field has been changed to.

So far I have considered to use a linked list approach where you simply persist rather than update an entity, and keep an ID to the previous entity. However, since relationships can change, I will not know how the linked entity was at the time of the previous update. What I mean by relationships can change: Say I have a Person entity which has a connection to another Person entity. If I only hold on to the ID of the other Person, I cannot know if the other Persons fields have been updated, e.g. if the other Person has for example changed its name field. Please see below for further explenation.

Another approache might be to sequentially save every change to the database, and simply revert back to a given change, e.g. save every sql query ever made.

Does anyone know a proper way to handle this? Thanks in advance.

Update

Lets say I have an entity which is called Person (see below). The Person can have many parents and children. Lets also say a user can update values in a existing Person. Whenever a user for example updates the name field, I want to save this change, so other users can revert the change, if desired. As mentioned, if I only hold on to the ID of the parent, I cannot know wether the Person with that ID has changed or not. For example if the parents name was updated.

Person {
    int id;
    String name; 
    List<Person> parents;
    List<Person> children;
}

In conclusion: I need to display a list of this Person entity for whenever it has been updated. In this list I need to see what the Persons fields did contain, but also how its parents and children looked at the time of the given change.


原文:https://stackoverflow.com/questions/46749691
更新时间:2023-06-05 14:06

最满意答案

查看RESTRequest.php的代码,有两种情况会抛出此异常:

  • 返回带有未知错误代码的JSON结果集(未知含义与200 OK不同)
  • 根本没有返回JSON结果集

所以我怀疑连接不正常。 要了解更多信息,您应该在代码中捕获异常并对其进行评估:

它可能看起来像这样(我对Java更熟悉):

try {
    $d = new Client(
        "http://jasper.server.com/jasperserver-pro",
        "username",
        "password",
        "organization"
    );  

    $info = $d->serverInfo();

} catch (RESTRequestException $e) {
    echo 'RESTRequestException:';
    echo 'Exception message:   ',  $e->getMessage(), "\n";
    echo 'Set parameters:      ',  $e->parameters, "\n";
    echo 'Expected status code:',  $e->expectedStatusCodes, "\n";
    echo 'Error code:          ',  $e->errorCode, "\n";
}

如果仍有错误,您可以检查以下内容:

  • 您可以从部署此代码的服务器访问jasper服务器吗? 有时例如防火墙设置会干扰。
  • 组织的调用是否与服务器中组织属性中的定义完全相同? (打开存储库/右键单击organization / properties / resource-id)

Looking into the code of RESTRequest.php there are two cases in which this exception is thrown:

  • A JSON result set with an unknown error code is returned (unknown meaning different from 200 OK)
  • No JSON result set is returned at all

So I suspect the connection isn't working properly. To find out more, you should catch the exception in your code and evaluate it:

It could look something like this (I'm more familiar with Java):

try {
    $d = new Client(
        "http://jasper.server.com/jasperserver-pro",
        "username",
        "password",
        "organization"
    );  

    $info = $d->serverInfo();

} catch (RESTRequestException $e) {
    echo 'RESTRequestException:';
    echo 'Exception message:   ',  $e->getMessage(), "\n";
    echo 'Set parameters:      ',  $e->parameters, "\n";
    echo 'Expected status code:',  $e->expectedStatusCodes, "\n";
    echo 'Error code:          ',  $e->errorCode, "\n";
}

If there is still an error, you can check the following:

  • Can you reach the jasper server from the server where this code is deployed? Sometimes e.g. firewall settings can interfere.
  • Is the organization called exactly like defined in the properties of the organization in the server? (Open repository / right click on organization / properties / resource-id)

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)