0

The way I understand it, in the context of relational databases, a database has referential integrity if all referenced attribute values exist. In other words, if a value of one attribute references a value of another attribute, then the referenced value must exist. However, I cannot find any clear definition of referential integrity constraints. What exactly is a referential integrity constraint?

mooncow
  • 413
  • 4
  • 11
  • https://en.wikipedia.org/wiki/Referential_integrity Referential integrity is, yes. same values in two different tables. But which values/columns are we talking about? We define that in a constraint. Typically in SQL that's a 'Foreign Key' constraint. More generally it's an **inclusion dependency**, see the wiki. – AntC Sep 18 '19 at 21:44
  • @AntC So in this SQL code `CREATE TABLE book (id INT REFERENCES resource (id) PRIMARY KEY, /* details omitted */);` is the fact that the values of `book.id` are constrained to being equal to the values of `resource.id` the _referential integrity constraint_? – mooncow Sep 18 '19 at 22:02
  • It's hard to imagine how you could not find a definition of "referential integrity constraint" or separately DB "integrity" & "referential integrity" & the various relevant meanings of "constraint" so that you could "show any research effort". PS [Re "constraint" & "FK"](https://stackoverflow.com/a/24317478/3404097) [What are database constraints? \[closed\]](https://stackoverflow.com/q/2570756/3404097) – philipxy Sep 19 '19 at 11:23

0 Answers0