问题标签 [database-integrity]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
67 浏览

mysql - SQL:试图了解如何使用安全的并发访问和修改数据库

所以,我目前正在使用 MySQL,但任何 SQL 答案都可能会,因为我试图理解一般概念。

所以线程安全在并发环境中显然很重要。我主要使用 Java 进行编程,并且我总是非常小心地编写代码来保护其可变状态以避免线程冲突。

但是,在 SQL 中,我对如何实现同样的安全级别感到非常困惑。所以我要从我不知道的东西开始,继续我感到困惑的东西,然后从那里开始。

首先,我所知道的是交易。禁用自动提交、使用保存点、回滚等。据我了解,事务在提交时是原子的。

但我也看到了对显式锁定语句和并发模型(乐观、悲观)的引用。而且我真的不知道所有这些都适合。我也不想只对所有事情都使用事务并假设它是安全的。除非我完全理解它,否则我不会编写代码,我不想留下任何机会。

此外,触发器、过程等呢?如何将它们与事务一起使用?我如何确保那里的原子性?

我觉得我有点过于复杂了,但我正在寻找一个全面、明确的解释,以说明如何确保多个线程和用户可以安全地修改数据库。不完全是 ELI5,因为我对 SQL 的理解比这更好,但它真正彻底地解释了这个过程。

谢谢。在我的搜索中,我没有在此站点上找到与此问题相匹配的匹配项,但如果它是重复的,我深表歉意,并要求在锁定此问题之前提供指向适当答案的链接。

0 投票
1 回答
295 浏览

python - python2.7中的SqlAlchemy检查数据库表中是否存在唯一值的好方法是什么

session.merge在 SqlAlchemy 中使用 向表中插入数据UniqueConstraint,这对于多个列来说很常见,例如,我的 ORM 类具有以下内容:

我应该使用filter还是filter_bywith_and来检查我要插入的数据是否会违反这个唯一约束,或者它是IntegrityError通过try - except构造捕获的正确方法吗?

0 投票
1 回答
1215 浏览

mysql - SQL 完整性约束违规:1062 重复条目

当我从我的会计软件外部更新我的 Magento 商店中的产品时,我在日志中收到以下错误:

我该如何解决?

0 投票
3 回答
2308 浏览

python - django注册中的完整性错误

所以我在 django 1.8 中遇到了这个错误。和 django-registration-redux 1.1 。它不让我从 3 周开始睡觉。帮助会很好。

完整追溯

这是我的registration_form.html

设置.py 文件

如果还有其他问题需要回答,请告诉我,我是框架和 django 的新手。所以我真的不太了解它。

0 投票
1 回答
403 浏览

kdb - KDB/Q 中是否有任何方法可以检查分区表的完整性?

KDB/Q 中是否有任何方法可以检查分区表的完整性?

非常感谢您的帮助!

0 投票
2 回答
572 浏览

hibernate - Spring JPA + Hibernate:OneToMany 双向持久化

如何在 oneToMany 关系中保留子实体?

在注册创建时,如果注册列在付款表中不可为空:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:列“注册”不能为空

但是,如果注册可以为空,则创建付款但注册列为 null :

在此处输入图像描述

直到发生异常并执行“HH000010:在批处理发布时它仍然包含 JDBC 语句”。

请你能帮助我,禁用 Hibernate 批处理或了解有什么问题吗?

0 投票
0 回答
1318 浏览

magento - Magento 1 到 Magento 2 | 数据迁移工具 | 完整性检查 + 偏移

我想使用 Data-Migration-Tool 将数据从 Magento 1 迁移到 Magento 2。(我正在使用 wamp 在本地 Windows 机器上工作)

Magento 1 —> v1.6.0.0

Magento 2 —> v2.1.2

我在数据迁移过程中遇到了很多错误。(可以进行设置迁移)

所以我的问题是正常错误吗?

你认为它只是扩展表/字段吗?

我想只保留源数据库(客户、订单等)而不进行扩展修改。

我需要帮助。非常感谢 !!!

0 投票
1 回答
341 浏览

sql-server - 如何使用 SQL Server 确保数据完整性?

我在 SQL Server 中有一个包含数十亿行的表。我想确保数据是只读的(不可变的),并且在插入数据库后始终不会更改。

我目前的想法是使用SHA3 哈希算法来制作哈希链。

上述解决方案有以下缺点:

  1. 如果有数十亿行,则可能需要很长时间,因为每个记录散列都与前一条记录的散列相关。

  2. 它不允许并行计算。

考虑到性能,确保数据完整性的最实用方法是什么?

0 投票
0 回答
470 浏览

sql-server - 由于 IO 操作失败,数据库 XXXX(数据库 ID 8)的临时数据库快照已被标记为可疑

我正在为 DBCC 检查做 OLA hallengren 工作

当作业按计划运行时,我得到以下错误

由于 IO 操作失败,数据库 XXXX(数据库 ID 8)的临时数据库快照已被标记为可疑。

在错误日志日志中,我可以看到以下错误

操作系统在文件“L:\MSSQL10_50.PSPAC01\MSSQL\DATA\XXXXX.ndf:MSSQL_DBCC10”中的偏移量 0x00002fc8f40000 处写入期间向 SQL Server 返回错误 665(由于文件系统限制,无法完成请求的操作) . SQL Server 错误日志和系统事件日志中的其他消息可能会提供更多详细信息。这是威胁数据库完整性的严重系统级错误情况,必须立即纠正。完成完整的数据库一致性检查 (DBCC CHECKDB)。这个错误可能是由许多因素引起的;有关详细信息,请参阅 SQL Server 联机丛书。

操作系统在文件“R:\MSSQL10_50.PSPAC01\MSSQL\DATA\XXXXX.ndf:MSSQL_DBCC10”中的偏移量 0x00006a63e28000 处写入期间向 SQL Server 返回错误 665(请求的操作无法完成) . SQL Server 错误日志和系统事件日志中的其他消息可能会提供更多详细信息。这是威胁数据库完整性的严重系统级错误情况,必须立即纠正。完成完整的数据库一致性检查 (DBCC CHECKDB)。这个错误可能是由许多因素引起的;有关详细信息,请参阅 SQL Server 联机丛书。

注意:但是当我手动运行相同的作业时,它运行良好

我已经检查了两个驱动器的碎片整理,但输出表明“无需进行碎片整理”

这个问题如何解决,下面是图片的链接

0 投票
1 回答
289 浏览

database-design - Separating tv series entities in database design

I am designing the database for an application for tv series and movies. As I was studying the data that will have to be saved, I noticed that films, tv series, tv series seasons and tv series episodes have very similar data.

All of them have a title, air date, cast list, crew list, composers, director list, description, soundtrack, rate, rating, icon (or images), views, trailers, genres etc. It can be said that all of them also have a type (some variable that determines whether it is a season, film, tv series or episode).

There are some differences (ex. a film and an episode have streams, while tv series and seasons don't). There could be more differences in the future, but especially films and episodes seem very similar.

I was considering that maybe it makes sense to store all this information in the same table. The type would tell me what kind of item this is. Episodes would have a season identifier and a tv series identifier. Seasons would have a tv series identifier, to travel back and forth between tv serie - season - episode. Seasons and episodes also will need a number (season number, episode number).

There are obviously other tables, like the genre table, the stream table etc.

On the other hand, querying for certain information with such a design can get complex. For example, if I want to list all tv series with a certain number of episodes or the tv series whose episode streams are stored on a particular CDN (in this application it will be necessary), I would either have to make separate queries, or use subqueries. There are many other cases where keeping all 4 item types seems to complicate things. Since I have to use sequelize (node js ORM) instead of raw queries, I know from previous experience that it will lead to messy code and bad performance.

Would it be bad design or breaking entity integrity if I separated the items in different tables?