Questions tagged [referential-integrity]

Referential integrity is a property of data which requires the value of an attribute/column of a relation table to exist as a value of another attribute/column in another relation table

For referential integrity to hold in a relational database, any field in a table that is declared a foreign key can contain either a null value, or only values from a parent table's primary key or a candidate key. In other words, when a foreign key value is used it must reference a valid, existing primary key in the parent table.

http://en.wikipedia.org/wiki/Referential_integrity

353 questions
4
votes
1 answer

Does SQLite coupled with NHibernate support referential integrity / foreign keys?

I have been reading a bit about NHibernate with SQLite, figuring it might be a very good option when I need lightweight database handling. I've read the following (and the links) which talk about how the NHibernate SQLite dialect does not support…
Max
  • 4,345
  • 8
  • 38
  • 64
4
votes
1 answer

Tests throw exception saying user lacks privilege or object not found: REFERENTIAL_INTEGRITY after update HSQLDB to 2.0.0

Recently I upgraded my maven HSQL dependency to org.hsqldb:hsqldb:2.0.0 from version 1.8.1.2. However all the tests that used HSQLDB failed, with an exception saying: org.hsqldb.HsqlException: user lacks privilege or object not found:…
newguy
  • 5,668
  • 12
  • 55
  • 95
4
votes
2 answers

see what drop table cascade constraints deleted from database

Is there any way (a command that I can add in the top of the script file) to know what exactly has been dropped from database when executing : DROP TABLE MyTable CASCADE CONSTRAINTS The way I'm doing it now is to select all referential integrity…
maryam
  • 147
  • 3
  • 11
4
votes
2 answers

Best practise for polymorphic associations in MYSQL

I have a database with tables: clients (client_id) and companies (company_id). Both clients and companies can have addresses (address_id), stored in the addresses table. Is it better practice to: Have 2 extra tables linking to companies and…
4
votes
1 answer

How are consistency violations handled in event sourcing?

First of all, let me state that I am new to Command Query Responsibility Segregation and Event Sourcing (Message-Drive Architecture), but I'm already seeing some significant design benefits. However, there are still a few issues on which I'm…
4
votes
2 answers

How can you check for foreign key references for a list of records before attempting to delete any of these records in MySQL?

Is there a way, when you have a list of records, to check if each of these records have foreign key references before you attempt to delete any of these records? As an example, if I have a list of borrowers and a list of books, you should not be…
Stevio
  • 383
  • 3
  • 12
4
votes
2 answers

Integrity constraint violation in Magento custom module

I have a similar probelm to Integrity constraint violation creating Product in Magento (unanswered) but I am creating a custom Observer that hooks into the catalog_product_save_after event - based on this tutorial:…
Mr Benn
  • 466
  • 1
  • 6
  • 19
3
votes
1 answer

Should referential integrity from the database be unit tested?

Lets assume I have a Customer and Order table. When I do a Customer_Delete_Test do you also Assert if the related Orders are deleted too or do you rely on the referential integrity between the tables like On Cascade Delete ?
Pascal
  • 12,265
  • 25
  • 103
  • 195
3
votes
1 answer

Oracle - referential integrity with multiple types of data

I'm working on a set of database tables in Oracle and trying to figure out a way to enforce referential integrity with slightly polymorphic data. Specifically, I have a bunch of different tables--hypothetically, let's say I have Apples, Bananas,…
StilesCrisis
  • 15,972
  • 4
  • 39
  • 62
3
votes
1 answer

zend adapter beginTransaction() and commit() fails

I am facing a strange issue The Zend_DB_Adapter's beginTrasaction() and commit() methods don't seem to be working as expected. I have INSERT statements (in a FOR LOOP) enclosed in beginTrasaction() and commit() methods. But even when error occurs…
krishna
  • 3,547
  • 5
  • 27
  • 29
3
votes
2 answers

Is it possible to prevent delete but not an insert with foreign key?

I have two tables that I would like to link with a single-column foreign key. A normal parent-child type thing. The problem I'm trying to solve is that the nature of the system is such that the child can arrive before the parent exists (the child…
pomo
  • 2,251
  • 1
  • 21
  • 34
3
votes
4 answers

Oracle: FK referring PK in multiple parent tables

In Oracle 10g, is it possible to define referential integrity constraints for a Foreign Key to refer to Primary Key in multiple parent tables. Eg: DEPT_AMER DEPT_ID 10 11 12 DEPT_APAC DEPT_ID 13 14 15 DEPT_EMEA DEPT_ID 16 17 18 EMP EMP_ID …
museshad
  • 498
  • 1
  • 8
  • 18
3
votes
0 answers

Django GenericForeignKey Referential INtegrity

I'm new to django programming, and trying to get to grips with GenericForeignKeys. I've managed to create a generic foreign key which stores in the database, but the model does not appear to enforce referential integrity, (i.e. I can create a…
3
votes
4 answers

Tools, rules or processes for checking internal consistency of XML config files

I've worked on projects that have very complex XML configuration, and one problem that's faced is maintaining the internal consistency of the XML. In this case I don't mean the strict XML schema consistency, but rather the higher level relation…
3
votes
2 answers

Ever ok to remove referential integrity on database design for 'right to be forgotten' deletion of user records?

I'm currently reviewing a database design that in order to deal with the removal of user records, in order to deal with requirements such as DPA and EU GDPR Right to be Forgotten, is proposing not to enforce referential integrity between the user…
Si Downes
  • 51
  • 4