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
votes
3 answers

How to establish referential integrity constraint?

1 create table pointofinterest( 2 pointid number not null, 3 describe varchar(30), 4 opentime varchar(30), 5 closetime varchar(30), 6 townid varchar(30), 7 constraint pk primary key (pointid), 8 constraint fk foreign…
SP45
  • 15
  • 1
  • 8
-1
votes
1 answer

Microsoft Access Referential Integrity Error Message but Primary Key Values Match

I am working on appending some additional data from an Excel spreadsheet to an existing Microsoft Access database. The primary key is "RecordID", however, when I go to create the one-to-one relationship between a current table and the new table with…
-1
votes
1 answer

Using Trigger to maintain referential integrity

I am trying to write a SQL trigger for any insert on the relation Section and it should ensure that the time slot id value that is being inserted is valid. The Section relation Thanks in advance!
sfk
  • 50
  • 5
-1
votes
1 answer

MySQL DB Foreign Key

What are the pros and cons of creating table relationships in a MySQL database using queries (JOINS) as opposed to doing it with DDL using Foreign key and referential integrity constraints? I have received a database that has not relationships (No…
The Georgia
  • 1,005
  • 7
  • 23
  • 59
-1
votes
1 answer

Referential integrity list of tables for truncation

I was wondering if there is a quick and efficient way to order tables in PostgreSQL so that, if I ran a DELETE FROM they would all succeed without breaking referential integrity. E.g. if the tables were USER -->* ACCOUNT -->*…
amphibient
  • 29,770
  • 54
  • 146
  • 240
-1
votes
3 answers

Trouble storing uploaded file into MySql

Hi I'm currently developing a quick prototype for my degree project. I have a previous form where users will select some options from dynamic dropdowns and when these have been saved into the tables the next page is for a user to upload a file. This…
-2
votes
1 answer

Reference different tables depending on a condition

I have a table [Advertiser] and a table [Ad] that has a N..M relationship that an Advertiser can have many Ads so that [Ad] will have a column referncing [Advertiser]. An Advertiser can either be a company or a person and the data entered into the…
shurda
  • 67
  • 8
-5
votes
1 answer

Can referential integrity be enforced using alter table?

Is there a way to enforce referential integrity without foreign keys? Is there a way to achieve what I am trying to do below with alter table statement? ALTER TABLE no.Man WITH CHECK ADD CONSTRAINT chk_Son_Weight CHECK (Son_Weight IN (Select…
1 2 3
23
24