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

How do you determine if a database table relationship merits enforcing referential integrity?

I have an application where the majority of the database tables have a strong relationship to one other table. Currently I am enforcing referential integrity with foreign keys, but I'm wondering if this is really the best approach. Data in the…
user4903
2
votes
3 answers

data redundancy

Can referential integrity constraints help in addressing data redundancy problems?
shridatt
  • 896
  • 4
  • 15
  • 39
2
votes
2 answers

How to check referential integrity in Cerberus?

Consider the following Cerberus schema: { 'employee': { 'type': 'list', 'schema': { 'type': 'dict', 'schema': { 'id': {'required': True, 'type': 'integer'}, 'name': {'required': True, 'type': 'string'} } …
Bruno Rijsman
  • 3,715
  • 4
  • 31
  • 61
2
votes
3 answers

SQL Server 2005 Replication Integrity Violations SQL Server, Error number: 28549

I am hoping someone can help me with a really bizarre problem. When users sync their device they are getting this error: The row operation cannot be reapplied due to an integrity violation. Check the Publication filter. [ Table = …
2
votes
1 answer

First database with referential integrity constraints -- suggestions, feedback, errors?

TARGET_RDBMS: MySQL-5.X-InnoDB ("X" equals current stable release) BACKGROUND: Building my first database with true referential integrity constraints, in an effort to get feedback, after creating the "real" DDL, I've made an abstraction that I…
blunders
  • 3,619
  • 10
  • 43
  • 65
2
votes
2 answers

Add a reference column using migration having non standard primary key column

I have a model which has a non-rails conventional primary key. class Guoid < ActiveRecord::Base self.primary_key = :guoid end and related migration class CreateGuoids < ActiveRecord::Migration def change create_table :guoids, id: false do…
2
votes
2 answers

Single column/primary key only table for referential integrity?

Maybe i'm going about this wrong but my working on a database design for one of my projects. I have an entity with a classification column which groups up entities into convenient categories for the user. These classifications are predefined and…
MerickOWA
  • 7,453
  • 1
  • 35
  • 56
2
votes
3 answers

How can I find out which table a foreign key references?

I have a database without documentation. There is a table which has a column language_id which is a foreign key to another table. I want to know which table that foreign key references. I don't want to find out just by looking by eye at all the…
Ania David
  • 1,168
  • 1
  • 15
  • 36
2
votes
2 answers

Maintaining referential integrity

Given the schema: MACHINE_TYPE { machine_type } MACHINE { machine, machine_type } SORT_PLAN { sort_plan, machine_type } SCHEDULE { day_of_week, machine, sort_plan } and the business rule: A sort plan can be assigned to any machine of the same…
Dave
  • 4,546
  • 2
  • 38
  • 59
2
votes
1 answer

Enforce relationship match in FileMaker

I have two FileMaker tables that are linked using a relationship. The relationships matches based on the content of two fields: TableA.Foo matches TableB.Foo TableA.Bar matches TableB.Bar Is there a way to enforce constraints on this relationship…
Sjlver
  • 1,227
  • 1
  • 12
  • 28
2
votes
1 answer

About like system (such as facebook like system) using myisam Mysql

One problem I have them is 'like system' such as facebook like system. I making the program using foreign hosting site having myisam mysql. as you know the myisam mysql has not transaction system. so it can not set key like foreign key to present…
2
votes
2 answers

Use SQL Server check constraints or Application logic to keep Referential Integrity on User Id?

For Audit purpose each of my Sql Server tables in a database has a 'LastUpdatedUserId' and 'CreateduserId' column These columns are foreign keys into a ApplicationUser table Strictly speaking there should be a Check Constraint for both columns in…
2
votes
1 answer

How to define @OneToMany in parent entity when child has composite PK?

My Parent class has two child classes: Child and ParentHobby. The Child class has a singular PK and the @OneToMany mapping on it works. The problem is that I don't know how to map it on the ParentHobby class, which has a composite…
amphibient
  • 29,770
  • 54
  • 146
  • 240
2
votes
1 answer

Proper DDD way to create and remove child in oneToMany relation?

I am struggling to find the proper DDD way to have a parent/child oneToMany relationship that: Ensures entities cannot exist in invalid state Exposes no unwanted methods (i.e. a clean API) I am using PHP and Doctrine2 but I guess this applies to…
2
votes
2 answers

How to reference groups of records in relational databases?

Humans | HumanID | FirstName | LastName | Gender | |---------+-----------+----------+--------| | 1 | Issac | Newton | M | | 2 | Marie | Curie | F | | 3 | Tim | Duncan | M | Animals | AmimalID |…