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
1
vote
1 answer

referential integrity in XML files without globally unique IDs

Maybe I'm not seeing the forest for the trees, but here it goes: I'm "designing" an XML document and have so far come up with something like the following: ...
n3rd
  • 5,989
  • 4
  • 39
  • 56
1
vote
1 answer

How can I make table unique, 'there is no unique constraint matching the referenced table'?

I am trying to make a database for a registration system. However I am running into the problem that I don't have a unique key for certain tables. I cannot make an artificial key because that would throw the integrity of the database out (it's not…
M. Barbieri
  • 512
  • 2
  • 13
  • 27
1
vote
1 answer

Table integrity with 4-table circular references

The following use case has been bugging me from time to time and it always annoyed me that I don't really know a solution for this. Recently I came across it once more: An object has 0 or more objectProperties; an object is used in 1 or more…
1
vote
2 answers

MYSQL: Cannot add or update a child row: a foreign key constraint fails

I am getting the error: Cannot add or update a child row: a foreign key constraint fails (mydb/requests, CONSTRAINT requests_ibfk_5 FOREIGN KEY (fixture_id) REFERENCES fixtures (fix_id) ON UPDATE CASCADE ON DELETE CASCADE) I have the following table…
Stephen Maher
  • 228
  • 5
  • 11
1
vote
0 answers

Foreign key integrity violation

I have two tables and there is a foreign key. Although I have defined conditions ON DELETE and ON UPDATE, when I delete a row from the BENEFIT table, I get an integrity error. The error is documented…
1
vote
0 answers

Ensure referencial integrity in matrix-esque database structures?

I hope you understand my problem. An excerpt of my MySQL database looks like that: To ensure data integrity two constraints must be implemented: Given an answer record, both "referencial paths" have to lead to the same exam record. Every…
1
vote
0 answers

trigger “an instructor cannot teach in two different classrooms in a semester in the same time slot.”

Show how to enforce the constraint “an instructor cannot teach in two different classrooms in a semester in the same time slot.” using a trigger (remember that the constraint can be violated by changes to the teaches relation as well as to the…
macintosh81
  • 189
  • 1
  • 12
1
vote
1 answer

Keys and integrity in truck database

I was learning about keys and integrity in database tables. I am having this database : I want to know that Do the tables exhibit entity integrity ? If Yes why and also do thet exhibit referential integrity ? Also what are the super key and…
ms8
  • 417
  • 2
  • 13
1
vote
1 answer

Entity Framework : A referential integrity constraint violation occurred when I do EntityState.Modified

I create a website in ASP.NET MVC 4. It's been so long that I have this error : A referential integrity constraint violation occurred. It's when i tried to update a entry in my db. Well when someone want to buy a product, i need to change the user…
1
vote
1 answer

Zend Framework - Problem with Database Table Recursive Cascading Deletes

My situation may be a bit abnormal, but I have foreign keys defined in my MySQL database, while enforcing referential integrity in the Zend_Db_Table classes. The tables use the InnoDB storage engine. When deleting a record, the Zend Framework will…
1
vote
3 answers

Cascade UPDATE to related objects

I've set up my database and application to soft delete rows. Every table has an is_active column where the values should be either TRUE or NULL. The problem I have right now is that my data is out of sync because unlike a DELETE statement, setting…
ngoue
  • 1,045
  • 1
  • 12
  • 25
1
vote
1 answer

PHP SQL Check Referential Integrity for whole DB

I was wondering if there was an option to check the referntial integrity of my database without checking everything manually. I must mention that I'm completely new to SQL and have the task to check the referential integrity. With the search I…
1
vote
1 answer

Foreign-Key constraint depending on category

I have a m:n connection between the table "Bill" and the tables "GeneralArticles", "CalculatedArticles" and "AdditionalRecords". These tables are straight-forward. Each has its own ID (Let's call them B_ID and for the other ones GA_ID, CA_ID and…
Qohelet
  • 1,459
  • 4
  • 24
  • 41
1
vote
1 answer

can i insert a value, in child table's Foreign Key Constraint, which is not yet created in parent table as primary key?

I have a relation: Contact Table - using contactNumber as PK Message Table - using messageID as PK Contact_Message - contains foreign keys for many to many mapping - used to populate inbox i.e. One Contact can have many messages sent/received…
1
vote
1 answer

MS Access - Enforce Referential Integrity - Multiple Table Foreign Key Constraints

I have created four tables in MS Access to describe allowable configurations of personal fire fighting equipment for use as part of an asset register. The details follow: TBL_1 : FIRE_CLASSIFICATION FIELDS : | PK | CLASS …