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

Entity Framework error, only when deleting "multiple" Parent then Child row

I'm building and MVC project using Entity-Framework 6 (code first). My database Data Models (code first): public class ParentNode { public int ParentNodeId { get; set; } public string SomeParentData { get; set; } //FK [Required] …
0
votes
1 answer

How to use cascade delete vs restrict for referential integrity with one-to-one record relationships?

I have a table CPT defined with TABLE cpt ( recid serial NOT NULL, ccpt text, cdesc text NOT NULL, ninsurance numeric(10,2), ncash numeric(10,2), ..... ) In which I wish to move the values ninsurance and ncash to another record…
0
votes
1 answer

implementing referntial integrity with php mysqli

i have three tabs in my Db: 1.pers_info(id(primary), name ,....) 2.contacts(c_id(primary), phone, email, ...) now 1 person can have multiple rows in contacts tab. thus to minimize redundancy i made another tab contact_relation(id (foregin key…
0
votes
1 answer

MySQL structural integrity versus simplicity?

My problem: On a PHP/MySQL application I have to distinguish the registered accounts from the simple visitors. Both of them can perform actions which are written into the database. Now I use a separate table for visitors and a separate table for…
Gábor DANI
  • 2,063
  • 2
  • 22
  • 40
0
votes
2 answers

MYSQL database modeler showing referential integrity in diagram view

Is there any database modeler for MySQL capable of showing referential integrity attributes (ON DELETE RESTRICT, ON UPDATE CASCADE ... ) in model diagram? Can Workbench do this like ERwin modeler shown image
sbrbot
  • 6,169
  • 6
  • 43
  • 74
0
votes
3 answers

Does SQL Server 2005 pass error message numbers back to the asp.net application?

I'd like to get the message number and severity level information from SQL Server upon execution of an erroneous query. For example, when a user attempts to delete a row being referenced by another record, and the cascade relationship is "no…
Matt
  • 1,041
  • 1
  • 16
  • 28
0
votes
2 answers

microsoft access relationships: referential integrity different databases linked tables

As far as my understanding goes, it's not possible to enforce referential activity (and cascade updates) between tables that come from two different database (even if the tables are all in split back-ends) Is this right? Is it even necessary to…
0
votes
1 answer

MySQL - Is there a way to preserve referential integrity of my data set?

Take the following data set: Users (int) (varchar) (varchar) (varchar) id | username | password | stuff | 1 john cat stuff 2 jack dog stuff 3 bill bird…
0
votes
1 answer

Before update trigger with referential integrity in oracle 11g

I want to understand what does before update in trigger means. I have a table called DEPT_MST where DEPT_ID is the primary key. It has 2 rows with DEPT_ID 1 and 2. Another table EMP has columns EMP_ID as primary key and EMP_DEPT_ID which is a…
0
votes
2 answers

Can I not enforce referential integrity in MySQL

I have a SQL table called "user" and a table "login" that has a foreign key constraint to a user. I want to be able to delete a row in the user table, even if there are login rows that reference it. Right now the database stops me from doing this.…
user2662692
  • 227
  • 5
  • 15
0
votes
0 answers

Referential integrity on UNION or VIEW

I already saw similar open issues, but my situation is slightly different. I have several tables which reference the same key value pair (a small integer and a string code). I want to build one table which accepts all these references from the…
Vadim Berman
  • 1,932
  • 1
  • 20
  • 39
0
votes
1 answer

web2py: sqlite3.IntegrityError'>(foreign key constraint failed)

I know this is nth time this question is being asked in the forum,but please i need your help as i am not able to figure out what i am doing wrong. Model db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) auth = Auth(db) service…
May
  • 1,158
  • 2
  • 13
  • 24
0
votes
1 answer

oracle get tables that reference given primary key value

In out DB we have a table called "AGENCY" with AGENCY_ID as primary key (PK). There are also about 30 tables that use AGENCY_ID as a foreign key (FK) which references PK in "AGENCY" table. Is there a way to count how many times a specific PK value…
ukie
  • 188
  • 2
  • 15
0
votes
1 answer

Oracle referential integrity against data range in PK table

Consider the following design: LEGAL_CASE table (columns) -------------------------------- LEGAL_CASE_ID APPELLATE_CRT_ID DISTRICT_CRT_ID TRIAL_CRT_ID with all courts being defined in a lookup table COURT table…
amphibient
  • 29,770
  • 54
  • 146
  • 240
0
votes
2 answers

Adding new child records to a parent table in entity framework 6

I have 3 tables: Account: Id, Name User: Id, AccountId, Name UserDetail: Id, UserId, Phone Entitites: public partial class Account { public Account() { this.Users = new HashSet(); } public int Id{get;set;} public…
amythn04
  • 388
  • 2
  • 11