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
0
votes
2 answers

Limit value of element to value in other element XSD

Given the following type:
Svish
  • 152,914
  • 173
  • 462
  • 620
0
votes
3 answers

Yii integrity constraint exception handling with user friendly message

I am using this model code to delete a record. public function actionDelete($id) { $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser …
ali asad
  • 1,329
  • 4
  • 17
  • 23
0
votes
1 answer

MVC application - where to store reference data

I am working on an application using the Yii framework, so its MVC-style. I have a record type "person", which contains information about membership. Members come in two types: adults & kids. With the kids, SOME of them we know their ages and…
johnmac
  • 166
  • 1
  • 7
0
votes
1 answer

Zend Framework - Cascading Deleting Using Table Data Mapper pattern

My problem getting Zend Framework to provide a DRI layer can now be summarized as such. Using the class definitions below I am able to delete the user but not the related comment through my local UserController "public/users/delete/userId/22", even…
Tommy Cox Green
  • 633
  • 1
  • 4
  • 20
0
votes
1 answer

django integrity error, many to many relationship

That's my models.py: class User(models.Model): email = models.EmailField() def __unicode__(self): return str(self.email) class Link(models.Model): link = models.URLField() users = models.ManyToManyField(User,…
0
votes
1 answer

database design (lists of many different items, with custom fields)

I’m working on a project where you work with all kinds of items. What it is is of no importance, it’s the database design I’m worried about. If someone could give me some insight in how I should create the layout of my database for this, or just…
dreagan
  • 2,426
  • 6
  • 24
  • 34
0
votes
1 answer

SQL Server Foreign Key relationship against two tables

I have a DB where 3 of the tables have a FK relationship inasmuch as: Table A has 2 (relevant) fields: TypeId (int) LinkId (int) Tables B and C each have a primary key that maps to the LinkId in Table A. If the TypeId in Table A is 1 then the…
Guy
  • 65,082
  • 97
  • 254
  • 325
0
votes
1 answer

referential integrity into rdf-like mysql table?

I suspect that this is going to sound like a stupid question, but, having just migrated a bunch of identikit lookup tables of the form (id, value, is_default) into a single large general lookup table at my boss's behest of the form (id, type, value,…
sanbikinoraion
  • 752
  • 2
  • 8
  • 12
0
votes
1 answer

MySQL constraint using fixed "hard-coded" value - is this possible?

I have a table "comments", containing a basic auto-inc PK "id" field, and also a "type" field. At another tables, I want to have referential integrity applying a CONSTRAINT to comments.id AND ALSO the "type", using a fixed value for the type value.…
J. Bruni
  • 20,322
  • 12
  • 75
  • 92
0
votes
1 answer

How can I detect if a dependent is missing from an EF entity?

Example situation (I have asked this more directly and received no feedback, so please excuse the abstract example but I am just trying to pose the question better): For brevity (actual models are hundreds of lines). A database is modeled to…
Travis J
  • 81,153
  • 41
  • 202
  • 273
-1
votes
2 answers

SQL Server deletion dilemma

CREATE TABLE [dbo].[ProjectTasks] ( [TaskID] [int] IDENTITY(1,1) NOT NULL, ... [DefaultTaskValue] [int] NULL ) ALTER TABLE [dbo].[ProjectTasks] ADD CONSTRAINT [PK_ProjectTasks] PRIMARY KEY CLUSTERED ( [TaskID] ASC ) ALTER TABLE…
kpollock
  • 3,899
  • 9
  • 42
  • 61
-1
votes
2 answers

Self referencing table with foreign key issue

I have a small table, below is a screenshot: There is a parent node which references back to the ID. Every row had a parent except the home page (for obvious reasons). Here's the code with some bits removed for brevity: CREATE TABLE…
John Ohara
  • 2,821
  • 3
  • 28
  • 54
-1
votes
1 answer

Is referential integrity commutative (i.e., is it direction-dependent)?

I've had some behavior in MS Access 2019 that surprised me and I've boiled it down to the following: I've got two tables with a different number of records: I need to establish an outer join between them that includes all records from table [test…
NewSites
  • 1,402
  • 2
  • 11
  • 26
-1
votes
1 answer

Integrity constraint violated - Parent key not found

I am creating two tables each having one primary key column and another column that is used to link both tables using a foreign key. create table t1(a number not null primary key, b number); create table t2 ( c…
-1
votes
2 answers

PostgreSQL - NULL References

I have a data model for Tasks and Equipments. Sometimes a Task needs some Equipment to be completed, sometimes it doesn't. Task table create table task ( id serial primary key , task_name varchar(80) ) Equipment table create table equipment…
gmwill934
  • 609
  • 1
  • 10
  • 27
1 2 3
23
24